Summary

This assignment is about linked lists and the problem domain is grocery lists.

Starting point

A template has been uploaded on iLearn as assignment3_groceries_template.zip.

PART A

Complete the method equals in class GroceryListItem. Two grocery items are considered equal if they have the same name (case insensitive) and same maximum price to be paid. Quantity of that item required is irrelevant while checking for equality. When you completed the method, it should pass the test testEquals in GroceryListItemTest class.

PART B

This part requires you using javas linked list class to complete 5 methods in class JavaGroceryList that acts as a wrapper class for a (linked) list of grocery list items.

The class JavaGroceryList contains a linked list of GroceryListItem objects as an instance variable and the methods in this class operate on this linked list.

The requirements for the methods you need to complete is extensively provided as javadoc headers above the methods. There is a comment //to be completed in the methods that need to be completed. The names of the methods to be completed (in suggested order of completion) are:

  • indexOf
  • worstCaseShoppingTotal
  • priciest
  • addItem
  • common

Each method is worth 10 marks. The tests for these methods are provided in class JavaGroceryListTest

For 15 marks, you also need to write a client JavaGroceryListClient that uses JavaGroceryList that creates a JavaGroceryList object and adds some items to the list. The details about the items to be added is provided in JavaGroceryListClient.

PART C

This part requires you to create your own linked list using the Node class. The class CustomGroceryList contains a linked list of GroceryListItem objects whose rst node is firstItem.

The requirements for the methods you need to complete is extensively provided as javadoc headers above the methods. There is a comment //to be completed in the methods that need to be completed. The names of the methods to be completed (in suggested order of completion) are:

  • size
  • get
  • indexOf
  • addItem
  • merge
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.