-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfessor.java
More file actions
49 lines (40 loc) · 1.17 KB
/
Professor.java
File metadata and controls
49 lines (40 loc) · 1.17 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
48
49
import java.util.ArrayList;
public class Professor extends Person{
private ArrayList<Course> teachingCourses;
public Professor(String name, String id){
super(name,id);
teachingCourses = new ArrayList<>();
}
public void assignCourse(Course c){
//adds course to teaching list
teachingCourses.add(c);
System.out.println("\nCourse assigned\n");
}
public void removeTeachingCourse( String rmCourse){
if(teachingCourses.isEmpty()) System.out.println("The list is empty");
for(Course n: teachingCourses){
if(n.getCourseTitle().toLowerCase().equals(rmCourse.trim().toLowerCase())){
teachingCourses.remove(n);
System.out.println("\nThe course was removed\n");
return;
}
}
System.out.println("There was an error or the list doesn't contain that course");
}
public void listTeachingCourses(){
if(teachingCourses.size()==0){
System.out.println("This teacher has no courses");
}
int count =1;
System.out.printf("\n");
for(Course c: teachingCourses){
System.out.printf("Course #: %d | Title: %s | Credits: %d \n",count,c.getCourseTitle(),c.getCourseCredits());
count++;
}
System.out.printf("\n");
}
@Override
public String getRole(){
return "Professor";
}
}