Advertisement
Guest User

Untitled

a guest
Feb 4th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public class Student implements Comparable<Student> {
  2. private String name;
  3. private int course;
  4. private String specialty;
  5. private int facultyNumber;
  6. private double averageSuccess;
  7.  
  8. public Student(String name, int course, String specialty, int facultyNumber, double averageSuccess) {
  9. this.name = name;
  10. this.course = course;
  11. this.specialty = specialty;
  12. this.facultyNumber = facultyNumber;
  13. this.averageSuccess = averageSuccess;
  14. }
  15.  
  16. public String getName() {
  17. return name;
  18. }
  19.  
  20. public int getCourese() {
  21. return course;
  22. }
  23.  
  24. public String getSpecialty() {
  25. return specialty;
  26. }
  27.  
  28. public int getFacultyNumber() {
  29. return facultyNumber;
  30. }
  31.  
  32. public double getAverageSuccess() {
  33. return averageSuccess;
  34. }
  35.  
  36. @Override
  37. public int compareTo(Student student) {
  38.  
  39. if (this.averageSuccess > student.getAverageSuccess()) {
  40. return 1;
  41. } else if (this.averageSuccess < student.getAverageSuccess()) {
  42. return -1;
  43. } else {
  44. return 0;
  45. }
  46. }
  47.  
  48. @Override
  49. public String toString() {
  50. String result;
  51.  
  52. result = this.name + " " + this.course + " " + this.specialty + " " + this.facultyNumber + " " + this.averageSuccess;
  53. return result;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement