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
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
 import java.util.ArrayList;
3
 import java.util.ArrayList;
4
-import java.util.Collection;
5
 import java.util.Iterator;
4
 import java.util.Iterator;
6
 
5
 
7
 /**
6
 /**

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

2
 
2
 
3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
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
 import java.util.Map;
8
 import java.util.Map;
6
 
9
 
7
 /**
10
 /**
8
  * @author leon on 11/12/2018.
11
  * @author leon on 11/12/2018.
9
  */
12
  */
10
 public class ZipCodeWilmington {
13
 public class ZipCodeWilmington {
14
+    HashMap<Student, Double> students = new HashMap<>();
15
+
11
     public void enroll(Student student) {
16
     public void enroll(Student student) {
17
+        students.put(student, 0.0);
12
     }
18
     }
13
 
19
 
14
     public Boolean isEnrolled(Student student) {
20
     public Boolean isEnrolled(Student student) {
15
-        return null;
21
+        return students.containsKey(student);
16
     }
22
     }
17
 
23
 
18
     public void lecture(double numberOfHours) {
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
     public Map<Student, Double> getStudyMap() {
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
  * @author leon on 11/12/2018.
4
  * @author leon on 11/12/2018.
5
  */
5
  */
6
 public class Student {
6
 public class Student {
7
+    private Integer id;
8
+    private Double totalStudyTime;
9
+
7
     public Student() {
10
     public Student() {
8
-        this(null);
11
+        this.id = 0;
12
+        this.totalStudyTime = 0.0;
9
     }
13
     }
10
 
14
 
11
     public Student(Integer id) {
15
     public Student(Integer id) {
16
+        this.id = id;
17
+        this.totalStudyTime = 0.0;
12
     }
18
     }
13
 
19
 
14
     public void learn(Double amountOfHours) {
20
     public void learn(Double amountOfHours) {
21
+        totalStudyTime += amountOfHours;
15
     }
22
     }
16
 
23
 
17
     public Double getTotalStudyTime() {
24
     public Double getTotalStudyTime() {
18
-        return null;
25
+        return totalStudyTime;
19
     }
26
     }
20
 }
27
 }