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