瀏覽代碼

Getting there

NiraParikh 6 年之前
父節點
當前提交
e84d57b921

+ 11
- 7
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java 查看文件

@@ -1,7 +1,9 @@
1 1
 package rocks.zipcode.io.quiz4.collections;
2 2
 
3
+import java.util.ArrayList;
3 4
 import java.util.Collection;
4 5
 import java.util.Iterator;
6
+import java.util.List;
5 7
 
6 8
 /**
7 9
  * @author leon on 11/12/2018.
@@ -18,6 +20,7 @@ public class SimpleStringGroup implements Iterable, Collection {
18 20
         this.indexOfValue = indexOfValue;
19 21
     }
20 22
 
23
+    List<String> list = new ArrayList<>();
21 24
     SimpleStringGroup group = new SimpleStringGroup();
22 25
 
23 26
     public SimpleStringGroup() {
@@ -29,23 +32,23 @@ public class SimpleStringGroup implements Iterable, Collection {
29 32
     }
30 33
 
31 34
     public void insert(String string) {
32
-        this.string = string;
35
+        list.add(string);
33 36
     }
34 37
 
35 38
     public Boolean has(String valueToInsert) {
36
-       if(group.contains(valueToInsert)){
39
+       if(list.contains(valueToInsert)){
37 40
             return true;
38 41
         }
39 42
         return false;
40 43
     }
41 44
 
42 45
     public String fetch(int indexOfValue) {
43
-      return String.valueOf(group.contains(indexOfValue));
46
+      return String.valueOf(list.contains(indexOfValue));
44 47
 
45 48
     }
46 49
 
47 50
     public void delete(String valueToInsert) {
48
-        this.valueToInsert = valueToInsert;
51
+        group.delete(valueToInsert);
49 52
     }
50 53
 
51 54
     @Override
@@ -55,12 +58,13 @@ public class SimpleStringGroup implements Iterable, Collection {
55 58
 
56 59
     @Override
57 60
     public boolean isEmpty() {
58
-        return true;
61
+
62
+      return list.isEmpty();
59 63
     }
60 64
 
61 65
     @Override
62 66
     public boolean contains(Object o) {
63
-        if(string.equals(o)){
67
+        if(list.equals(o)){
64 68
             return true;
65 69
         }
66 70
         return false;
@@ -74,7 +78,7 @@ public class SimpleStringGroup implements Iterable, Collection {
74 78
     @Override
75 79
     public boolean add(Object o) {
76 80
 
77
-        return group.add(o);
81
+        return true;
78 82
     }
79 83
 
80 84
     @Override

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

@@ -25,6 +25,7 @@ public class ZipCodeWilmington {
25 25
 //        this.numberOfHours = numberOfHours;
26 26
 //        double numOfHrsPerLearner = numberOfHours/student.length;
27 27
 //
28
+//        Student[] students;
28 29
 //        for(Student student : students){
29 30
 //            student.learn(numOfHrsPerLearner);
30 31
 //        }

+ 1
- 1
src/main/java/rocks/zipcode/io/quiz4/generics/GenericUtils.java 查看文件

@@ -22,7 +22,7 @@ public class GenericUtils {
22 22
     }
23 23
 
24 24
     public static Set<? extends Comparable> getOriginalSet() {
25
-        if(powerSet().equals(originalSet)){
25
+        if(!powerSet().equals(originalSet)) {
26 26
         }
27 27
 
28 28
         return originalSet;

+ 6
- 3
src/main/java/rocks/zipcode/io/quiz4/generics/Group.java 查看文件

@@ -1,19 +1,22 @@
1 1
 package rocks.zipcode.io.quiz4.generics;
2 2
 
3
-import java.util.*;
3
+
4
+import java.util.ArrayList;
5
+import java.util.Iterator;
6
+import java.util.List;
4 7
 
5 8
 /**
6 9
  * @author leon on 18/12/2018.
7 10
  */
8 11
 public class Group<_>{
9 12
 
10
-    List<_> list = new ArrayList<>();
13
+  List<_> list = new ArrayList<>();
11 14
 
12 15
 //    private int indexOfValue;
13 16
 //    private _ value;
14 17
 
15 18
     public Group(){
16
-        throw new UnsupportedOperationException("Method not yet implemented");
19
+        //throw new UnsupportedOperationException("Method not yet implemented");
17 20
     }
18 21
 
19 22
     public Integer count(){

+ 3
- 3
src/main/java/rocks/zipcode/io/quiz4/generics/MyStack.java 查看文件

@@ -8,13 +8,13 @@ import java.util.Stack;
8 8
  * @author leon on 11/12/2018.
9 9
  */
10 10
 public class MyStack<SomeType> implements Iterable {
11
-    Stack<SomeType> stack= new Stack <>();
11
+    Stack<SomeType> stack = new Stack<>();
12 12
 
13
-    private SomeType i;
13
+//    private SomeType i;
14 14
 
15 15
     public MyStack() {
16 16
 
17
-        throw new UnsupportedOperationException("Method not yet implemented");
17
+//        throw new UnsupportedOperationException("Method not yet implemented");
18 18
     }
19 19
 
20 20
     public Boolean isEmpty() {