-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy pathCourse.java
More file actions
44 lines (33 loc) · 1.18 KB
/
Course.java
File metadata and controls
44 lines (33 loc) · 1.18 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.launchcode;
import java.util.ArrayList;
import java.util.Objects;
public class Course {
private String name;
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 String toString() {
return "Course{" +
"name='" + name + '\'' +
", topic='" + topic + '\'' +
", instructor=" + instructor +
", enrolledStudents=" + enrolledStudents +
'}';
}
@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(name, course.name) && Objects.equals(instructor, course.instructor);
}
@Override
public int hashCode() {
return Objects.hash(name, instructor);
}
// TODO: Add your custom 'equals' method here. Consider which fields should match in order to call two
// Course objects equal.
}