Nick Satinover před 6 roky
rodič
revize
9940e853af

+ 22
- 5
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java Zobrazit soubor

@@ -1,31 +1,48 @@
1 1
 package rocks.zipcode.io.quiz4.collections;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.Collection;
5
+import java.util.Iterator;
6
+
3 7
 /**
4 8
  * @author leon on 11/12/2018.
5 9
  */
6
-public class SimpleStringGroup {
10
+public class SimpleStringGroup implements Iterable {
11
+    ArrayList<String> s = new ArrayList<>();
12
+
7 13
     public SimpleStringGroup() {
8
-        throw new UnsupportedOperationException("Method not yet implemented");
14
+        // throw new UnsupportedOperationException("Method not yet implemented");
9 15
     }
10 16
 
11 17
     public Integer count() {
12
-        return null;
18
+        return s.size();
13 19
     }
14 20
 
15 21
     public void insert(String string) {
22
+        s.add(string);
16 23
     }
17 24
 
18 25
     public Boolean has(String valueToInsert) {
19
-        return null;
26
+        if (s.contains(valueToInsert)){
27
+            return true;
28
+        }
29
+        return false;
20 30
     }
21 31
 
22 32
     public String fetch(int indexOfValue) {
23
-        return null;
33
+        return s.get(indexOfValue);
24 34
     }
25 35
 
26 36
     public void delete(String valueToInsert) {
37
+        s.remove(valueToInsert);
27 38
     }
28 39
 
29 40
     public void clear() {
41
+        s.clear();
42
+    }
43
+
44
+    @Override
45
+    public Iterator iterator() {
46
+        return s.iterator();
30 47
     }
31 48
 }