Assume these implementation details about a stack:
the stack is implemented using an array called elements
topIndex is the index of the topmost element on the stack
The following is one possible implementation of the operation top:
Object top() throws EmptyException
{
if (size() > 0)
return elements[topIndex];
else
throw(new EmptyException());
}
Part 1: Identify the contract implicitly defined by this method
That is: Specify its precondition and postcondition
Part 2: Try to suggest another contract
How is this new contract different from the first one?
A