Question: Use Java programming language. This is all i am provided with. I need to complete the following given code. 2)Write a repOK method and a
Use Java programming language. This is all i am provided with. I need to complete the following given code.
2)Write a repOK method and a constructor for creating an empty receipt, based on the rep below. (30 points)
public class GroceryReceipt
{
private List _groceries; // never null, contains no nulls private int _totalPrice;
// in cents, always >= 0 and = total price of all groceries
}
The grocery class includes the method
public class Grocery
{ ...........
/** return the price of this item in cents, >= 0
*/ public int getPrice()
{ .....
}
}
3)Write the next() method iterator that yields the squares in order (1, 4, 9, 16, 25, ). Also, include below the representation and rep invariants needed to support this iterator. (30 points)
public Integer next()
{
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
