thulasi il y a 6 ans
Parent
révision
7193deacb6

+ 3
- 2
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java Voir le fichier

@@ -14,9 +14,10 @@ public class ComparableTreeSet<_> {
14 14
 
15 15
 
16 16
     public ComparableTreeSet() {
17
+
17 18
     }
18 19
 
19
-    public Integer compareTo(ComparableTreeSet<_> o) {
20
-        return null;
20
+    public int compareTo(ComparableTreeSet<_> o) {
21
+        return 0;
21 22
     }
22 23
 }

+ 0
- 1
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java Voir le fichier

@@ -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.List;
6 5
 
7 6
 /**

+ 23
- 3
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java Voir le fichier

@@ -2,23 +2,43 @@ package rocks.zipcode.io.quiz4.collections;
2 2
 
3 3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
4 4
 
5
-import java.util.Map;
5
+import java.util.*;
6 6
 
7 7
 /**
8 8
  * @author leon on 11/12/2018.
9 9
  */
10 10
 public class ZipCodeWilmington {
11
+    List<Map.Entry<Student, Double>>cohort;
12
+
13
+    public ZipCodeWilmington() {
14
+        cohort = new ArrayList<>();
15
+    }
16
+
11 17
     public void enroll(Student student) {
18
+        Map.Entry<Student, Double> entry = new AbstractMap.SimpleEntry<>(student, 0.0);
19
+        cohort.add(entry);
12 20
     }
13 21
 
14 22
     public Boolean isEnrolled(Student student) {
15
-        return null;
23
+        for(Map.Entry entry : cohort){
24
+            if(entry.getKey().equals(student))
25
+                return true;
26
+        }
27
+        return false;
16 28
     }
17 29
 
18 30
     public void lecture(double numberOfHours) {
31
+        for(Map.Entry entry : cohort) {
32
+            Student s = (Student) entry.getKey();
33
+            s.learn(numberOfHours);
34
+        }
19 35
     }
20 36
 
21 37
     public Map<Student, Double> getStudyMap() {
22
-        return null;
38
+        Map<Student, Double> map = new HashMap<>();
39
+
40
+        for(Map.Entry entry : cohort)
41
+            map.put((Student)entry.getKey(), (Double)entry.getValue());
42
+        return map;
23 43
     }
24 44
 }

+ 8
- 3
src/main/java/rocks/zipcode/io/quiz4/objectorientation/PalindromeObject.java Voir le fichier

@@ -1,21 +1,26 @@
1 1
 package rocks.zipcode.io.quiz4.objectorientation;
2 2
 
3
+import rocks.zipcode.io.quiz4.fundamentals.PalindromeEvaluator;
4
+
3 5
 /**
4 6
  * @author leon on 18/12/2018.
5 7
  */
6 8
 public class PalindromeObject {
9
+    String word;
10
+
7 11
     public PalindromeObject(String input) {
12
+        word = input;
8 13
     }
9 14
 
10 15
     public String[] getAllPalindromes(){
11
-        return null;
16
+        return PalindromeEvaluator.getAllPalindromes(word);
12 17
     }
13 18
 
14 19
     public Boolean isPalindrome(){
15
-        return null;
20
+       return PalindromeEvaluator.isPalindrome(word.toLowerCase());
16 21
     }
17 22
 
18 23
     public String reverseString(){
19
-        return null;
24
+        return PalindromeEvaluator.reverseString(word);
20 25
     }
21 26
 }

+ 11
- 2
src/main/java/rocks/zipcode/io/quiz4/objectorientation/StringAssembler.java Voir le fichier

@@ -1,17 +1,26 @@
1 1
 package rocks.zipcode.io.quiz4.objectorientation;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
3 6
 /**
4 7
  * @author leon on 11/12/2018.
5 8
  */
6 9
 public class StringAssembler {
10
+    char c;
11
+    String result;
12
+
7 13
     public StringAssembler(Character delimeter) {
14
+        c = delimeter;
15
+        result = "";
8 16
     }
9 17
 
10 18
     public StringAssembler append(String str) {
11
-        return null;
19
+        result += str + c;
20
+        return this;
12 21
     }
13 22
 
14 23
     public String assemble() {
15
-        return null;
24
+        return this.result.substring(0,result.length()-1);
16 25
     }
17 26
 }

+ 8
- 3
src/main/java/rocks/zipcode/io/quiz4/objectorientation/StringEvaluatorObject.java Voir le fichier

@@ -1,21 +1,26 @@
1 1
 package rocks.zipcode.io.quiz4.objectorientation;
2 2
 
3
+import rocks.zipcode.io.quiz4.fundamentals.StringEvaluator;
4
+
3 5
 /**
4 6
  * @author leon on 19/12/2018.
5 7
  */
6 8
 public class StringEvaluatorObject {
9
+    String word;
10
+
7 11
     public StringEvaluatorObject(String str) {
12
+        word = str;
8 13
     }
9 14
 
10 15
     public String[] getAllPrefixes() {
11
-        return null;
16
+        return StringEvaluator.getAllPrefixes(word);
12 17
     }
13 18
 
14 19
     public String[] getCommonPrefixes(String secondInput) {
15
-        return null;
20
+        return StringEvaluator.getCommonPrefixes(word, secondInput);
16 21
     }
17 22
 
18 23
     public String getLargestCommonPrefix(String secondInput) {
19
-        return null;
24
+        return StringEvaluator.getLargestCommonPrefix(word, secondInput);
20 25
     }
21 26
 }

+ 9
- 2
src/main/java/rocks/zipcode/io/quiz4/objectorientation/Student.java Voir le fichier

@@ -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
+    double totalStudyTime;
8
+    int id;
9
+
7 10
     public Student() {
8
-        this(null);
11
+        totalStudyTime = 0.0;
12
+        id = 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 this.totalStudyTime;
19 26
     }
20 27
 }