Pabl0o0

Untitled

Apr 4th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public class Student implements Comparator {
  2.  
  3. private int numer;
  4. private String nazwisko;
  5. private String imie;
  6. private double ocena;
  7.  
  8. public int getNumer() {
  9. return numer;
  10. }
  11. public void setNumer(int numer) {
  12. this.numer = numer;
  13. }
  14. public String getNazwisko() {
  15. return nazwisko;
  16. }
  17. public void setNazwisko(String nazwisko) {
  18. this.nazwisko = nazwisko;
  19. }
  20. public String getImie() {
  21. return imie;
  22. }
  23. public void setImie(String imie) {
  24. this.imie = imie;
  25. }
  26. public double getOcena() {
  27. return ocena;
  28. }
  29. public void setOcena(double ocena) {
  30. this.ocena = ocena;
  31. }
  32.  
  33. public Student(int numer, String nazwisko, String imie, double ocena){
  34. setNumer(numer);
  35. setNazwisko(nazwisko);
  36. setImie(imie);
  37. setOcena(ocena);
  38. }
  39. public Student() {
  40. // TODO Auto-generated constructor stub
  41. }
  42. @Override
  43. public String toString() {
  44. return "Student numer: "+ numer +" " + imie + " "+ nazwisko +" numer indeksu: " +" ocena: "
  45. + ocena;
  46. }
  47. public void compare(Student st1, Student st2) {
  48. // TODO Auto-generated method stub
  49. if (st1.getImie().compareTo(st2.getImie())>0){
  50. Student tmp = st1;
  51. st1 = st2;
  52. st2 = tmp;
  53. }
  54.  
  55. }
  56.  
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment