-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmain.java
More file actions
33 lines (24 loc) · 856 Bytes
/
main.java
File metadata and controls
33 lines (24 loc) · 856 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
32
33
package Jamiir;
import java.util.ArrayList;
import java.util.List;
public static void main(String[] args) {
Student s1 = new Student(1, "Jordan", "Smith",
"jsmith@email.com", 2, 3.8);
Student s2 = new Student(2, "Marcus", "Brown",
"mbrown@email.com", 1, 2.9);
Instructor instructor = new Instructor(3, "Dr.", "Rivera",
"rivera@email.com", "Computer Science");
instructor.addStudent(s1);
instructor.addStudent(s2);
// Polymorphism — no instanceof needed
List<Person> people = new ArrayList<>();
people.add(s1);
people.add(s2);
people.add(instructor);
for (Person p : people) {
System.out.println(p.getSummary());
}
System.out.println();
instructor.printRoster();
}
}