-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathematics.java
More file actions
executable file
·45 lines (40 loc) · 1.96 KB
/
Mathematics.java
File metadata and controls
executable file
·45 lines (40 loc) · 1.96 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
/*
File Name: Mathematics.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 Mathematics extends Department{
//This is the constructor of the class that initializes the fields.
//It takes in an array of Teacher objects, an array of Course objects, and an integer as parameters and creates a Department object.
public Mathematics(ArrayList<Teacher> mathTeachers, ArrayList<Course> mathCourses, int number){
departmentNum = number;
teacherList = mathTeachers;
courseOffered = mathCourses;
acl = determineACL();
}
//This overrides the abstract method in the Department class.
//It determines the ACL based on the number of courses a teacher is able to teach and his/her experience of teaching.
//If more than one teacher has the maximum combination, then the ACL is the teacher whose name will appear first in the list if it is sorted alphabetically.
//It takes in no parameters 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 longest experience.
for (int i = 1; i < teacherList.size(); i ++){
int experienceDif = temACL.compareToExperience(teacherList.get(i));
int teachingDivDif = temACL.compareToTeachingDiversity(teacherList.get(i));
if (experienceDif + teachingDivDif < 0){
temACL = teacherList.get(i);
}
else if (experienceDif + teachingDivDif == 0){
if (teacherList.get(i).compareToName(temACL) < 0){
temACL = teacherList.get(i);
}
}
}
return temACL;
}
}