-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputerStudies.java
More file actions
executable file
·47 lines (41 loc) · 2.09 KB
/
ComputerStudies.java
File metadata and controls
executable file
·47 lines (41 loc) · 2.09 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
45
46
47
/*
File Name: ComputerStudies.java
Description: The following program creates a specific department object and implements some
department-related functions.
*/
//This imports all necessary packages.
import java.util.*;
//This is the declaration of the class.
public class ComputerStudies extends Department{
//This is the constructor of the class that initializes the fields.
//It takes an array of Teacher objects, an array of Course objects, and an integer as parameters and creates a Department object.
public ComputerStudies(ArrayList<Teacher> computerTeachers, ArrayList<Course> computerCourses, int number){
departmentNum = number;
teacherList = computerTeachers;
courseOffered = computerCourses;
acl = determineACL();
}
//This overrides the abstract method in the Department class.
//It determines the ACL based on the diversity of courses the teach is able to teach.
//If more than one teacher has the maximum number of courses a teacher can teach, then the ACL
//will be given to the teacher whose name will appear first when the list is sorted alphabetically.
//It takes in no parameter and returns a Teacher object.
public Teacher determineACL(){
//This initializes the ACL to be the first teacher in the array.
Teacher temACL = teacherList.get(0);
//This loops through the teacher list to find the teacher with the most diverse teaching ability.
for (int i = 1; i < teacherList.size(); i ++){
//This checks if the teacher array in the list has more diversity in the number of courses he/she can teach.
if (temACL.compareToTeachingDiversity(teacherList.get(i)) < 0){
temACL = teacherList.get(i);
}
else if (temACL.compareToTeachingDiversity(teacherList.get(i)) == 0){
//This returns the Teacher object who is lexicographically less.
if (teacherList.get(i).compareToName(temACL) < 0){
temACL = teacherList.get(i);
}
}
}
return temACL;
}
}