-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImprovedStack.java
38 lines (36 loc) · 1.26 KB
/
ImprovedStack.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* An implementation of a stack with additional methods.
*
* Classes implementing this interface must use a {@see List} as the
* underlying data structure to store the elements on the stack.
*
* Not all operations on a stack will always be successful. For
* example, a programmer may try to pop an element from an empty
* stack. Since we hace not covered exceptions yet, we need another
* mechanism to report errors. In order to do that, methods of this
* list will return a {@see ReturnObject} that will contain either an
* object or an error value of the right kind (as defined in {@see
* ErrorMessage}).
*
* @author PiJ
*/
public interface ImprovedStack extends Stack {
/**
* Returns a copy of this stack with the items reversed, the top
* elements on the original stack is at the bottom of the new
* stack and viceversa.
*
* @return a copy of this stack with the items reversed.
*/
public ImprovedStack reverse();
/**
* Removes the given object from the stack if it is
* there. Multiple instances of the object are all removed.
*
* Classes implementing this method must use method .equals() to
* check whether the item is in the stack or not.
*
* @param object the object to remove
*/
public void remove(Object object);
}