Browse Source

75 of 234

Nick Satinover 6 years ago
parent
commit
9364b6700e

+ 0
- 1
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java View File

@@ -1,7 +1,6 @@
1 1
 package rocks.zipcode.io.quiz4.collections;
2 2
 
3 3
 import java.util.ArrayList;
4
-import java.util.Collection;
5 4
 import java.util.Iterator;
6 5
 
7 6
 /**

+ 10
- 2
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java View File

@@ -2,23 +2,31 @@ package rocks.zipcode.io.quiz4.collections;
2 2
 
3 3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
4 4
 
5
+import java.util.ArrayList;
6
+import java.util.HashMap;
7
+import java.util.List;
5 8
 import java.util.Map;
6 9
 
7 10
 /**
8 11
  * @author leon on 11/12/2018.
9 12
  */
10 13
 public class ZipCodeWilmington {
14
+    HashMap<Student, Double> students = new HashMap<>();
15
+
11 16
     public void enroll(Student student) {
17
+        students.put(student, 0.0);
12 18
     }
13 19
 
14 20
     public Boolean isEnrolled(Student student) {
15
-        return null;
21
+        return students.containsKey(student);
16 22
     }
17 23
 
18 24
     public void lecture(double numberOfHours) {
25
+        //students.forEach((student, aDouble) -> student.learn(numberOfHours));
26
+        students.keySet().forEach(student -> student.learn(numberOfHours));
19 27
     }
20 28
 
21 29
     public Map<Student, Double> getStudyMap() {
22
-        return null;
30
+        return students;
23 31
     }
24 32
 }

+ 9
- 2
src/main/java/rocks/zipcode/io/quiz4/objectorientation/Student.java View File

@@ -4,17 +4,24 @@ package rocks.zipcode.io.quiz4.objectorientation;
4 4
  * @author leon on 11/12/2018.
5 5
  */
6 6
 public class Student {
7
+    private Integer id;
8
+    private Double totalStudyTime;
9
+
7 10
     public Student() {
8
-        this(null);
11
+        this.id = 0;
12
+        this.totalStudyTime = 0.0;
9 13
     }
10 14
 
11 15
     public Student(Integer id) {
16
+        this.id = id;
17
+        this.totalStudyTime = 0.0;
12 18
     }
13 19
 
14 20
     public void learn(Double amountOfHours) {
21
+        totalStudyTime += amountOfHours;
15 22
     }
16 23
 
17 24
     public Double getTotalStudyTime() {
18
-        return null;
25
+        return totalStudyTime;
19 26
     }
20 27
 }