|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectscranton.stack.StackViaLinear1
An implementation of the Stack interface applying the the Linear1 class via composition. Invariant: The class warranty is voided is a client directly applies any Linear1 class method.
| Field Summary | |
protected Linear1 |
actual
The stack is provided through aggregation, as a protected attribute within the class. |
| Constructor Summary | |
StackViaLinear1()
Constructs an empty stack. |
|
| Method Summary | |
Stack |
factory()
|
boolean |
isEmpty()
Stack does not change, returns true iff the stack is empty. |
java.lang.Object |
pop()
Decrease the size of the stack by one by removing and returning the object at the top. |
void |
push(java.lang.Object item)
Increase the size of the stack by one by placing item as the new top of the stack. |
java.lang.Object |
topOf()
Stack does not change, returns the reference to the top object in the stack. |
java.lang.String |
toString()
Returns a string representation of the stack. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Linear1 actual
| Constructor Detail |
public StackViaLinear1()
| Method Detail |
public boolean isEmpty()
Stack
|
S'=S Return S==() |
isEmpty in interface Stackpublic java.lang.Object topOf()
Stack
|
S!=() S'=S Return an-1 |
topOf in interface Stackpublic void push(java.lang.Object item)
Stack
| S'=(S, obj) |
push in interface Stackitem - The new top of stackpublic java.lang.Object pop()
Stack
|
S!=() S = (S', an-1) Return: an-1 |
pop in interface Stackpublic Stack factory()
public java.lang.String toString()
Stack
toString in interface Stack
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||