Bladeren bron

SimpleString done

Lauren Green 6 jaren geleden
bovenliggende
commit
086266bd63

+ 23
- 5
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java Bestand weergeven

@@ -1,17 +1,35 @@
1 1
 package rocks.zipcode.io.quiz4.collections;
2 2
 
3
+import java.util.TreeSet;
4
+
3 5
 /**
4 6
  * @author leon on 11/12/2018.
5 7
  */
6
-public class ComparableTreeSet<_> {
7
-    public ComparableTreeSet(_... arr) {
8
-    }
8
+public class ComparableTreeSet<T> implements Comparable<T> {
9 9
 
10
+    TreeSet<T> treeSet;
11
+
12
+    public ComparableTreeSet(T... arr) {
13
+        for(T item: arr){
14
+            treeSet.add(item);
15
+        }
16
+    }
10 17
 
11 18
     public ComparableTreeSet() {
12 19
     }
13 20
 
14
-    public Integer compareTo(ComparableTreeSet<_> o) {
15
-        return null;
21
+    public Integer compareTo(ComparableTreeSet<T> o) {
22
+
23
+        return 0;
24
+    }
25
+
26
+    public TreeSet<T> getTreeSet() {
27
+        return treeSet;
28
+    }
29
+
30
+    @Override
31
+    public int compareTo(T o) {
32
+
33
+        return 0;
16 34
     }
17 35
 }

+ 32
- 5
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java Bestand weergeven

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

+ 11
- 0
src/main/java/rocks/zipcode/io/quiz4/collections/ZipCodeWilmington.java Bestand weergeven

@@ -2,12 +2,23 @@ package rocks.zipcode.io.quiz4.collections;
2 2
 
3 3
 import rocks.zipcode.io.quiz4.objectorientation.Student;
4 4
 
5
+import java.util.List;
5 6
 import java.util.Map;
6 7
 
7 8
 /**
8 9
  * @author leon on 11/12/2018.
9 10
  */
10 11
 public class ZipCodeWilmington {
12
+
13
+    List<Student> cohort;
14
+
15
+    public ZipCodeWilmington(List<Student> cohort) {
16
+        this.cohort = cohort;
17
+    }
18
+
19
+    public ZipCodeWilmington() {
20
+    }
21
+
11 22
     public void enroll(Student student) {
12 23
     }
13 24