YauhenMardan

Student

Dec 5th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Objects;
  4.  
  5. public class Student extends Learner{
  6.  
  7. private int course;
  8.  
  9. public Student(String surname, String eduInstitution, double meanMark, int course) {
  10. super(surname, eduInstitution, meanMark);
  11. this.course = course;
  12. }
  13.  
  14. public int getCourse() {
  15. return course;
  16. }
  17.  
  18. public void setCourse(int course) {
  19. this.course = course;
  20. }
  21.  
  22. @Override
  23. public String toString() {
  24. StringBuffer stringBuffer= new StringBuffer(surname);
  25. stringBuffer.append(" ");
  26. stringBuffer.append(eduInstitution);
  27. stringBuffer.append(" ");
  28. stringBuffer.append(meanMark);
  29. stringBuffer.append(" ");
  30. stringBuffer.append(course);
  31. return stringBuffer.toString();
  32. }
  33.  
  34. @Override
  35. public boolean equals(Object o) {
  36. if (this == o) return true;
  37. if (!(o instanceof Student)) return false;
  38. if (!super.equals(o)) return false;
  39. Student student = (Student) o;
  40. return getCourse() == student.getCourse();
  41. }
  42.  
  43. @Override
  44. public int hashCode() {
  45. return Objects.hash(super.hashCode(), getCourse());
  46. }
  47. }
Add Comment
Please, Sign In to add comment