浏览代码

got a few more to pass

Whitney Martinez 6 年前
父节点
当前提交
6ab912f8e8

+ 6
- 9
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java 查看文件

@@ -9,14 +9,11 @@ import java.util.*;
9 9
  */
10 10
 public class ZipCodeWilmington {
11 11
     private List<Student> students = new LinkedList<>();
12
-    HashMap<Student,Double> maps;
13
-
14
-
15
-    public void enroll(Student student) {
16
-        students.add(student);
17 12
 
18 13
 
19 14
 
15
+    public void enroll(Student student) {
16
+       students.add(student);
20 17
     }
21 18
 
22 19
     public Boolean isEnrolled(Student student) {
@@ -27,18 +24,18 @@ public class ZipCodeWilmington {
27 24
 
28 25
     public void lecture(double numberOfHours) {
29 26
         for (Student x: students) {
27
+
30 28
             x.learn(numberOfHours);
31
-            maps.put(x,x.getTotalStudyTime());
32
-            System.out.println(x);
33 29
         }
34 30
 
35 31
 
36 32
     }
37 33
 
38 34
     public Map<Student, Double> getStudyMap() {
35
+        HashMap<Student,Double> maps = new HashMap<>();
36
+        return maps;
37
+
39 38
 
40
-        maps.put(students.,student.getTotalStudyTime());
41 39
 
42
-        return maps;
43 40
     }
44 41
 }

+ 3
- 2
src/main/java/rocks/zipcode/io/quiz4/fundamentals/StringEvaluator.java 查看文件

@@ -9,13 +9,14 @@ import java.util.List;
9 9
 public class StringEvaluator {
10 10
     public static String[] getAllPrefixes(String string) {
11 11
         ArrayList<String> list = new ArrayList<>();
12
-        String start = "";
12
+        String seen = "";
13
+        int notseen = seen.length();
13 14
 
14 15
 
15 16
 
16 17
         for (int i = 0; i < string.length() ; i++) {
17 18
 
18
-            list.add(start);
19
+
19 20
         }
20 21
             return list.toArray(new String[0]);
21 22
     }

+ 24
- 11
src/main/java/rocks/zipcode/io/quiz4/objectorientation/StringAssembler.java 查看文件

@@ -1,5 +1,8 @@
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
  */
@@ -14,34 +17,44 @@ public class StringAssembler {
14 17
 
15 18
     }
16 19
 
17
-    public StringAssembler append(String str) {
18
-        StringAssembler sA = new StringAssembler(ch);
19
-        String[] split = str.split(" ");
20
-        String x = "";
21
-        StringBuffer sb = new StringBuffer();
22
-
23
-        for (int i = 0; i < str.length() ; i++) {
20
+    public StringAssembler(String str){
21
+        this.str = str;
22
+    }
24 23
 
24
+    public StringAssembler append(String str) {
25 25
 
26
+        int counter = 0;
27
+        String st = "";
28
+        StringBuilder sb = new StringBuilder();
29
+        List<String> list = new ArrayList<String>();
26 30
 
27
-            sb.append(split[i]);
28
-            sb.append(ch);
31
+            if(str != null) {
32
+                list.add(str);
33
+            }
34
+        for (int i = 0; i < list.size() ; i++) {
29 35
 
36
+            sb.append(str);
30 37
         }
31 38
 
32
-        x = sb.toString();
39
+        st = sb.toString();
33 40
 
41
+        StringAssembler sA = new StringAssembler(st);
34 42
 
35 43
         return sA;
36 44
 
45
+
37 46
     }
38 47
 
39 48
     public String assemble() {
40 49
 
50
+        StringBuffer sb = new StringBuffer();
51
+        String r = "";
41 52
 
42 53
 
54
+        sb.append(ch);
43 55
 
44
-       return null;
45 56
 
57
+        r = sb.toString();
58
+        return r;
46 59
     }
47 60
 }

+ 14
- 1
src/main/java/rocks/zipcode/io/quiz4/objectorientation/StringEvaluatorObject.java 查看文件

@@ -1,14 +1,27 @@
1 1
 package rocks.zipcode.io.quiz4.objectorientation;
2 2
 
3
+import rocks.zipcode.io.quiz4.fundamentals.StringEvaluator;
4
+
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+
3 8
 /**
4 9
  * @author leon on 19/12/2018.
5 10
  */
6 11
 public class StringEvaluatorObject {
12
+    String str;
7 13
     public StringEvaluatorObject(String str) {
14
+        this.str = str;
8 15
     }
9 16
 
10 17
     public String[] getAllPrefixes() {
11
-        return null;
18
+        List<String> listing = new ArrayList<>();
19
+
20
+        for (int i = 0; i < str.length(); i++) {
21
+           listing.add(str.substring(i));
22
+        }
23
+
24
+        return listing.toArray(new String[0]);
12 25
     }
13 26
 
14 27
     public String[] getCommonPrefixes(String secondInput) {