Lab 1: Shopping Cart Data Structure

Due Date and Submission Requirements


The goal of this lab is:


Directions

Using the code we've been working with this week (you should download a fresh set of files below). Do not change any code other than adding the body of the four methods described below (and the demo class for additional testing). You do not need to add any more instance fields or methods.
Fill in the body of the searchForItem(String name) method for the ShoppingCartArray and ShoppingCartLinkedList classes.
This method takes in an item name to search for in the shopping cart. If the item is found, the item is printed out. If the item is not in the shopping cart, then "[item_name] is not in the shopping cart" should be printed out.

Next, you will need to fill in the body of the removeItem(String name) method for the ShoppingCartArray and ShoppingCartLinkedList classes. This method takes in an item name to be removed from the data structure. Actually remove the entry, don’t just set it to null: In the array implementation, the array needs to shrink in size by 1 and in the linked list implementation, the Item object needs to be removed from the list (you can just use a method from the Linked List documentation). You can assume the item they are trying to remove exists somewhere in the data structure (ie they will never try to remove an item that does not exist). Additionally, there is no need to handle duplicate names.

That is four methods in total. You are welcome to change the demo class to test your code.

Required Output

When you run your program, it should look exactly like output seen in in this screenshot .

Starting Code

Assumptions

There won't be duplicate item names in the data structure

Users wont try to remove an item that does not exist

If you are removing an item with a quantity greater than one, it should still remove the entire item (not decrease the quantity by one)

Grading (10 points)

Grading deductions

If your code does not compile, you will receive an automatic zero