Question: public class Grocery implements Comparable { private String name; private String category; private int aisle; private float price; private int quantity; /** * Constructor of



public class Grocery implements Comparable {
private String name;
private String category;
private int aisle;
private float price;
private int quantity;
/**
* Constructor of Entry object. Objects that match name and category are considered identical
*
* @param name the name of the item in the entry
* @param category the category of the item in the entry
*/
public Grocery(String name, String category) {
this.name = name;
this.category = category;
this.aisle = -1;
this.price = 0.0f;
this.quantity = 0;
}
/**
* Constructor of Entry object.
*
* @param name the name of the item in the entry
* @param category the category of the item in the entry
* @param aisle the aisle where the item in the entry is located
* @param price the price of the item in the entry
* @param quantity the quantity of the item to purchase
*/
public Grocery(String name, String category, int aisle, float price,
int quantity) {
this.name = name;
this.category = category;
this.aisle = aisle;
this.price = price;
this.quantity = quantity;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getAisle() {
return aisle;
}
public void setAisle(int aisle) {
this.aisle = aisle;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
@Override
public String toString() {
return "Entry{" + "name=" + name + ", category=" + category
+ ", aisle=" + aisle + ", price=" + price + ", quantity="
+ quantity + '}';
}
@Override
public int compareTo(Grocery t) {
if (this.getName().toUpperCase().compareTo(t.getName().toUpperCase()) == 0) {
return this.getCategory().compareToIgnoreCase(t.getCategory().toUpperCase());
}
return this.getName().compareToIgnoreCase(t.getName().toUpperCase());
}
}
I need help with the TODO list. I having trouble understanding what I should be doing for this section of the program. It would be very grateful. Dreat public void testFind () { //Create grocery objects Grocery item - new Grocery("Harry Potter", "book", 3, 15.56, 2); Grocery item2 - new Grocery("Hunger Game", "book", 3, 10.5f, 3); !! Construct a shopping list ShoppingListArrayList instance - new ShoppingListArrayList(): W TODO Test the case of finding a grocery object when the shopping list is empty Be sure that 1 An Empty CollectionException instance is thrown in the case // Add item into the shopping list instance. add (iteml): instance.add(item2): assert True (2 - instance.size()); // TODO Test the case of finding a grocery Object which Index 13 larger than the shopping list site Be sure that 17 An IndexOutorBoundeException instance is thrown in the case 1 Test the case of finding a grocery object which index in negative Grocery item = instance. Find (-5); assert True (0 == 1): } catch (IndexOutorBoundaException ex) assert True (1-1) > catch (Exception ex) ( assert True (0 == 1): public class Grocery implements comparable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
