Question: ShoppingCartDriver class In a separate class, implement a test program (called a driver) to do the following actions: Create two ShoppingCarts with your choice of

ShoppingCartDriver class

In a separate class, implement a test program (called a driver) to do the following actions:

  • Create two ShoppingCarts with your choice of customer names.
  • Add at least three GroceryItems to the first ShoppingCart and at least five GroceryItems to the second ShoppingCart.
  • Test the special case where the GroceryItem has already been added (add() causes the existing item's quantity to be changed).
  • Test the special case where the array is too full to add another item.
  • Print both invoices in a nicely formatted output.
  • Your driver should also test all the methods in the ShoppingCart class (see p. 26-29 for a discussion of good testing).
  • Do not use a Scanner to read any inputs from the user. Instead, use hard coded values for the different methods' inputs.

Other Requirements

  • Draw a UML structure diagram showing the relationship between the classes in your solution. You may hand draw or use any tool of your choice but the diagram must be submitted in a format that I can read (one of .docx, .pdf, .jpg, .txt). If I cannot read it, I cannot grade it.
  • Draw a UML class diagram for your ShoppingCart class (may be combined with the structure diagram).
  • Note that automated tools often do not follow the conventions that I require.
  • Factor the classes as described above GroceryItem, ShoppingCart and ShoppingCartDriver are all in separate classes with private instance variables
  • Constants are normally declared as public
  • Comment the GroceryItem and ShoppingCart classes with Javadocs style comments (see Appendix H).
  • Use good coding style throughout (see slide deck 01-D Objects and Chapter 1 of your text) including
    • correct private/public access modifiers
    • consistent indenting
    • meaningful variable names
    • normal capitalization conventions
    • other aspects of easy-to-read code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!