1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16public
17class Stack2 extends AbstractStack {
18
19
20
21
22
23 private
24 java.util.Stack s;
25
26
27
28
29
30 public
31 Stack2() {
32 s = new java.util.Stack();
33 }
34
35
36
37
38
39
40
41 public
42 boolean isEmpty() {
43 return
44 s.empty();
45 }
46
47
48
49 public
50 Object top()
51 {
52 assert preTop() : "Stack2.top: empty stack";
53
54 return
55 s.peek();
56 }
57
58
59
60 public
61 void push(Object o) {
62 s.push(o);
63 }
64
65
66
67 public
68 void pop()
69 {
70 assert prePop() : "Stack2.pop: empty stack";
71 s.pop();
72 }
73
74
75
76}
77
78