Browse Source

82 of 234 Test passing

William Brown 6 years ago
parent
commit
d82c5b2d46
1 changed files with 23 additions and 6 deletions
  1. 23
    6
      src/main/java/rocks/zipcode/io/quiz4/generics/Group.java

+ 23
- 6
src/main/java/rocks/zipcode/io/quiz4/generics/Group.java View File

@@ -1,37 +1,54 @@
1 1
 package rocks.zipcode.io.quiz4.generics;
2 2
 
3
+import java.util.ArrayList;
3 4
 import java.util.Iterator;
4 5
 
5 6
 /**
6 7
  * @author leon on 18/12/2018.
7 8
  */
8
-public class Group<_> {
9
+public class Group<_> implements GroupInterface<_>{
10
+
11
+    ArrayList<_> group = new ArrayList<>();
12
+
9 13
     public Group() {
10
-        throw new UnsupportedOperationException("Method not yet implemented");
14
+
11 15
     }
12 16
 
13 17
     public Integer count() {
14
-        return null;
18
+        return group.size();
15 19
     }
16 20
 
17 21
     public void insert(_ value) {
22
+        group.add(value);
18 23
     }
19 24
 
20 25
     public Boolean has(_ value) {
21
-        return null;
26
+        return group.contains(value);
22 27
     }
23 28
 
24 29
     public _ fetch(int indexOfValue) {
25
-        return null;
30
+        return group.get(indexOfValue);
26 31
     }
27 32
 
28 33
     public void delete(_ value) {
34
+        group.remove(value);
29 35
     }
30 36
 
31 37
     public void clear() {
38
+        group.clear();
32 39
     }
33 40
 
34 41
     public Iterator<_> iterator() {
35
-        return null;
42
+        return group.iterator();
43
+    }
44
+
45
+    public String toString(){
46
+        String output = "[";
47
+        for(_ i : group){
48
+            output = output + i + ", ";
49
+        }
50
+        output = output.substring(0, output.length()- 2) + "]";
51
+
52
+        return output;
36 53
     }
37 54
 }