Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: *

    *
  1. The sequence is empty. *
  2. The last element has just been removed. *
  3. We advanced from the last element. *
* The code you write has no need to distinguish these situations. * @precondition true * @return true if at the end of the sequence */ public boolean atEnd() { assert wellFormed() : "Invariant failed at start of atEnd"; // TODO: Implement this code return false; // Our solution makes use of no conditionals (if/while/for/&&/||). }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

BPR always involves automation. Group of answer choices True False

Answered: 1 week ago

Question

=+How would you change the tone of voice?

Answered: 1 week ago