Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Objects;
- public class Student extends Learner{
- private int course;
- public Student(String surname, String eduInstitution, double meanMark, int course) {
- super(surname, eduInstitution, meanMark);
- this.course = course;
- }
- public int getCourse() {
- return course;
- }
- public void setCourse(int course) {
- this.course = course;
- }
- @Override
- public String toString() {
- StringBuffer stringBuffer= new StringBuffer(surname);
- stringBuffer.append(" ");
- stringBuffer.append(eduInstitution);
- stringBuffer.append(" ");
- stringBuffer.append(meanMark);
- stringBuffer.append(" ");
- stringBuffer.append(course);
- return stringBuffer.toString();
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Student)) return false;
- if (!super.equals(o)) return false;
- Student student = (Student) o;
- return getCourse() == student.getCourse();
- }
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), getCourse());
- }
- }
Add Comment
Please, Sign In to add comment