-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathCourse.java
More file actions
31 lines (23 loc) · 991 Bytes
/
Course.java
File metadata and controls
31 lines (23 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.launchcode.java.demos.lsn4classes2;
import java.util.ArrayList;
import java.util.Objects;
public class Course {
private String topic;
private Teacher instructor;
private ArrayList<Student> enrolledStudents;
// TODO: Add your custom 'toString' method here. Make sure it returns a well-formatted String rather than
// just the class fields.
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Course course = (Course) o;
return Objects.equals(topic, course.topic) && Objects.equals(instructor, course.instructor) && Objects.equals(enrolledStudents, course.enrolledStudents);
}
@Override
public int hashCode() {
return Objects.hash(topic, instructor, enrolledStudents);
}
// TODO: Add your custom 'equals' method here. Consider which fields should match in order to call two
// Course objects equal.
}