Parcourir la source

104 of 234 Test passing

William Brown il y a 6 ans
Parent
révision
5c7a70c490

+ 16
- 5
src/main/java/rocks/zipcode/io/quiz4/generics/MyStack.java Voir le fichier

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

+ 5
- 1
src/main/java/rocks/zipcode/io/quiz4/generics/SortedGroup.java Voir le fichier

@@ -4,15 +4,19 @@ package rocks.zipcode.io.quiz4.generics;
4 4
  * @author leon on 18/12/2018.
5 5
  */
6 6
 public class SortedGroup<_> extends Group<_> {
7
+
7 8
     @Override
8 9
     public void insert(_ value) {
10
+        super.group.add(value);
9 11
     }
10 12
 
11 13
     @Override
12 14
     public void delete(_ value) {
15
+        super.group.remove(value);
13 16
     }
14 17
 
15 18
     public Integer indexOf(_ firstValue) {
16
-        return null;
19
+        return super.group.indexOf(firstValue);
17 20
     }
21
+
18 22
 }