Browse Source

fifth push

Jacqueline Joson 6 years ago
parent
commit
8c02b4a46e

+ 6
- 3
src/main/java/rocks/zipcode/io/quiz4/collections/ComparableTreeSet.java View File

1
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
+import java.util.Comparator;
4
+import java.util.TreeSet;
5
+
3
 /**
6
 /**
4
  * @author leon on 11/12/2018.
7
  * @author leon on 11/12/2018.
5
  */
8
  */
6
-public class ComparableTreeSet<_> {
9
+public class ComparableTreeSet<_> extends TreeSet<ComparableTreeSet<_>>  implements Comparable <ComparableTreeSet <_>> {
7
     private _[] arr;
10
     private _[] arr;
11
+    private ComparableTreeSet<_> o;
12
+
8
     //
13
     //
9
     public ComparableTreeSet(_... arr) {
14
     public ComparableTreeSet(_... arr) {
10
         this.arr = arr;
15
         this.arr = arr;
11
     }
16
     }
12
 
17
 
13
-
14
     public ComparableTreeSet() {
18
     public ComparableTreeSet() {
15
     }
19
     }
16
 
20
 
17
     public int compareTo(ComparableTreeSet<_> o) {
21
     public int compareTo(ComparableTreeSet<_> o) {
18
         return 0;
22
         return 0;
19
     }
23
     }
20
-
21
 }
24
 }

+ 17
- 4
src/main/java/rocks/zipcode/io/quiz4/collections/SimpleStringGroup.java View File

1
 package rocks.zipcode.io.quiz4.collections;
1
 package rocks.zipcode.io.quiz4.collections;
2
 
2
 
3
+import java.util.Iterator;
4
+import java.util.function.Consumer;
5
+
3
 /**
6
 /**
4
  * @author leon on 11/12/2018.
7
  * @author leon on 11/12/2018.
5
  */
8
  */
6
-public class SimpleStringGroup {
9
+public class SimpleStringGroup implements Iterable{
7
     SimpleStringGroup ssg;
10
     SimpleStringGroup ssg;
8
     Integer count;
11
     Integer count;
9
 
12
 
10
-    public SimpleStringGroup() {
11
-        throw new UnsupportedOperationException("Method not yet implemented");
12
-    }
13
+//    public SimpleStringGroup() {
14
+//        throw new UnsupportedOperationException("Method not yet implemented");
15
+//    }
13
 
16
 
14
     public Integer count() {
17
     public Integer count() {
15
         return count;
18
         return count;
32
 
35
 
33
     public void clear() {
36
     public void clear() {
34
     }
37
     }
38
+
39
+    @Override
40
+    public Iterator iterator() {
41
+
42
+        return null;
43
+    }
44
+
45
+    @Override
46
+    public void forEach(Consumer action) {
47
+    }
35
 }
48
 }

+ 14
- 5
src/main/java/rocks/zipcode/io/quiz4/generics/MyStack.java View File

1
 package rocks.zipcode.io.quiz4.generics;
1
 package rocks.zipcode.io.quiz4.generics;
2
 
2
 
3
+import java.util.Collection;
4
+import java.util.Iterator;
5
+
3
 /**
6
 /**
4
  * @author leon on 11/12/2018.
7
  * @author leon on 11/12/2018.
5
  */
8
  */
6
-public class MyStack<SomeType> {
7
-    MyStack<SomeType> myStack = new MyStack<>();
8
-    public MyStack() {
9
-        throw new UnsupportedOperationException("Method not yet implemented");
10
-    }
9
+public class MyStack<SomeType> implements Iterable<SomeType> {
10
+    private int n;
11
+
12
+//    public MyStack() {
13
+//        throw new UnsupportedOperationException("Method not yet implemented");
14
+//    }
11
 
15
 
12
     public Boolean isEmpty() {
16
     public Boolean isEmpty() {
13
 
17
 
24
     public SomeType pop() {
28
     public SomeType pop() {
25
         return null;
29
         return null;
26
     }
30
     }
31
+
32
+    @Override
33
+    public Iterator iterator() {
34
+        return null;
35
+    }
27
 }
36
 }