Advertisement
niske

Untitled

Oct 23rd, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Comparator;
  3. import java.util.Objects;
  4.  
  5. import org.svetovid.io.SvetovidReader;
  6.  
  7. class Film implements Comparable<Film> {
  8. public final int idf;
  9. public final String naziv;
  10. public final String reditelj;
  11.  
  12. public Film(int idf,String naziv,String reditelj) {
  13. this.idf=idf;
  14. this.naziv=naziv;
  15. this.reditelj=reditelj;
  16. }
  17. public String toString() {
  18. return "ID filma: " + idf + "Naziv: " + "Reditelj:" + reditelj;
  19. }
  20. @Override
  21. public int compareTo(Film that) {
  22. int rezultat=Objects.compare(this.naziv, that.naziv, String.CASE_INSENSITIVE_ORDER);
  23. if(rezultat==0) {
  24. rezultat=this.idf-that.idf;
  25. }
  26. return rezultat;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement