Skip to content

Commit 15d2f54

Browse files
author
AmiyahJo
committed
fix: chaged assigned ta from hashmap back to an array list
feat: adds ta names , and an illlegal exception for invalid ta
1 parent 18424f5 commit 15d2f54

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/amiyahjones/JobReadinessProgram.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package com.codedifferently.lesson16.amiyahjones;
22

33
import java.util.ArrayList;
4-
// import java.util.Arrays;
5-
import java.util.HashMap;
64
import java.util.List;
75

86
public class JobReadinessProgram {
97
private final boolean isSuccessful;
108
ArrayList<String> students;
119
private final Level readinessLevel;
1210
private final int lecturePerWeek;
13-
private static final HashMap<Integer, String> teacherAssistants;
11+
private static final ArrayList<String> teacherAssistants = new ArrayList<>();
1412
private String assignedTA;
1513
private final String mentor;
1614
private final String socialSupport;
1715

16+
static {
17+
teacherAssistants.add("Rich");
18+
teacherAssistants.add("Vicente");
19+
teacherAssistants.add("Jordan");
20+
}
21+
1822
enum Level {
1923
Beginner ,
2024
Intermediate ,
@@ -26,9 +30,9 @@ public JobReadinessProgram(Level readinessLevel, boolean isSuccessful, String as
2630
this.readinessLevel = readinessLevel;
2731
this.isSuccessful = isSuccessful;
2832
lecturePerWeek = 3;
29-
this.assignedTA = null;
3033
mentor = "Anthony";
3134
socialSupport = "Estelle";
35+
this.assignedTA = assignedTA;
3236
}
3337

3438
public void addStudent(String studentName){
@@ -67,17 +71,16 @@ public String getSocialSupport() {
6771
return socialSupport;
6872
}
6973

70-
public List<String> teacherAssistants() {
71-
return teacherAssistants;
74+
public List<String> getTeacherAssistants() {
75+
return new ArrayList<>(teacherAssistants);
7276
}
7377

7478
public boolean assignTA(String taName) {
7579
if (teacherAssistants.contains(taName)) {
7680
this.assignedTA = taName;
7781
return true;
7882
} else {
79-
System.out.println("Not a TA. Please choose from: " + teacherAssistants);
80-
return false;
83+
throw new IllegalArgumentException("Not a TA. Please choose from: " + getTeacherAssistants());
8184
}
8285
}
8386

0 commit comments

Comments
 (0)