Question
make the comment to code by java please do all methods public int size( ) { assert wellFormed() : invariant failed at start of size;
make the comment to code by java please do all methods
public int size( ) { assert wellFormed() : "invariant failed at start of size"; // TODO: Implement this code. return 0; // size() should not modify anything, so we omit testing the invariant at the end }
/** * The first element (if any) of this sequence is now current. * @param - none * @postcondition * The front element of this sequence (if any) is now the current element (but * if this sequence has no elements at all, then there is no current * element). **/ public void start( ) { assert wellFormed() : "invariant failed at start of start"; // TODO: Implement this code. assert wellFormed() : "invariant failed at end of start"; }
/** * Accessor method to determine whether this sequence has a specified * current element (a Transaction or null) that can be retrieved with the * getCurrent method. This depends on the status of the cursor. * @param - none * @return * true (there is a current element) or false (there is no current element at the moment) **/ public boolean isCurrent( ) { assert wellFormed() : "invariant failed at start of isCurrent"; // TODO: Implement this code. return false; }
/** * Accessor method to get the current element of this sequence. * @param - none * @precondition * isCurrent() returns true. * @return * the current element of this sequence, possibly null * @exception IllegalStateException * Indicates that there is no current element, so * getCurrent may not be called. **/ public Transaction getCurrent( ) { assert wellFormed() : "invariant failed at start of getCurrent"; // TODO: Implement this code. return null; }
/** * Return true if we are at the end of the sequence. * This can happen in several different ways: *
- *
- The sequence is empty. *
- The last element has just been removed. *
- We advanced from the last element. *
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started