1
2
3
4
5
6
7
8
9
10
11
12public
13class SafeStack extends SimpleStack {
14
15
16
17
18
19
20
21
22
23 public
24 SafeStack(int max) {
25 super(max);
26 }
27
28
29
30 public
31 SafeStack() {
32 super();
33 }
34
35
36
37
38
39
40
41 public
42 Object top()
43 {
44 assert preTop() : "Stack underflow";
45
46 return
47 super.top();
48 }
49
50
51
52
53
54
55
56 public
57 void pop()
58 {
59 assert preTop() : "Stack underflow";
60
61 super.pop();
62 }
63
64}
65
66