Untitled
unknown
java
19 days ago
1.3 kB
5
Indexable
package ICS2606; public class Student { private String name; private int studentID; private String course; public Student(String name, int studentID, String course) { this.name = name; this.studentID = studentID; this.course = course; } // Getters public String getName() {return name;} public int getStudentID() {return studentID;} public String getCourse() {return course;} // Setters public void setName(String name) {this.name = name;} public void setStudentID(int studentID) {this.studentID = studentID;} public void setCourse(String course) {this.course = course;} // Overrides @Override public String toString() { return "name: " + name + ", studentID: " + studentID + ", course: " + course; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Student student = (Student) obj; return studentID == student.studentID && name.equals(student.name) && course.equals(student.course); } @Override public int hashCode() { return java.util.Objects.hash(name, studentID, course); } }
Editor is loading...
Leave a Comment