Brandon Defrancis 5 年 前
コミット
69d7228ecf
共有1 個のファイルを変更した8 個の追加18 個の削除を含む
  1. 8
    18
      src/main/java/rocks/zipcode/io/quiz3/collections/Student.java

+ 8
- 18
src/main/java/rocks/zipcode/io/quiz3/collections/Student.java ファイルの表示

@@ -14,33 +14,23 @@ import static rocks.zipcode.io.quiz3.objectorientation.enums.LabStatus.PENDING;
14 14
  */
15 15
 public class Student extends Lab {
16 16
 
17
-    private Lab lab;
18
-    private LabStatus labStatus;
17
+    private Lab lab = new Lab();
18
+    private LabStatus labStatus = INCOMPLETE;
19 19
 
20
-    private Map<Lab, LabStatus> mMap;
21
-
22
-    public Student(Lab lab, LabStatus labStatus) {
23
-        this.lab = lab;
24
-        this.labStatus = labStatus;
25
-    }
26
-
27
-    public Student(String labName, Lab lab, LabStatus labStatus) {
28
-        super(labName);
29
-        this.lab = lab;
30
-        this.labStatus = labStatus;
31
-    }
20
+    private HashMap<Lab, LabStatus> mMap;
32 21
 
33 22
     public Student() {
34 23
         this(new HashMap<>());
35 24
     }
36 25
 
37
-    public Student(Map<Lab, LabStatus> map) {
26
+    public Student(HashMap<Lab, LabStatus> map) {
38 27
         this.mMap = map;
39 28
     }
40 29
 
41 30
     public void setLabStatus(Lab lab, LabStatus labStatus) {
42
-        mMap.replace(lab, labStatus);
43
-    }
31
+        if (mMap.containsKey(lab)) {
32
+             mMap.replace(lab, labStatus);
33
+        }    }
44 34
 
45 35
     public void forkLab(Lab lab) {
46 36
         mMap.replace(lab, INCOMPLETE, PENDING);
@@ -53,7 +43,7 @@ public class Student extends Lab {
53 43
         if (mMap.containsKey(labName)) {
54 44
             return mMap.get(labName);
55 45
         }
56
-        return mMap.get(labName);
46
+        return PENDING;
57 47
     }
58 48
 
59 49