I am trying to finish this, but i keep getting a couple of errors. This is the instructions for the assignment.
(1) Extend the ItemToPurchase class per the following specifications:
string itemDescription - Initialized in default constructor to "none"
Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)
Public member methods
setDescription() mutator & getDescription() accessor (2 pts)
printItemCost() - Outputs the item name followed by the quantity, price, and subtotal
printItemDescription() - Outputs the item name and description.
(2) Create two new files:
ShoppingCart.java - Class definition
ShoppingCartManager.java - Contains main() method
Build the ShoppingCart class with the following specifications. Note: Some can be method stubs (empty methods) initially, to be completed in later steps.
String customerName - Initialized in default constructor to "none"
String currentDate - Initialized in default constructor to "January 1, 2016"
Parameterized constructor which takes the customer name and date as parameters (1 pt)
Public member methods
getCustomerName() accessor (1 pt)
getDate() accessor (1 pt)
Adds an item to cartItems array. Has parameter ItemToPurchase. Does not return anything.
Removes item from cartItems array. Has a string (an item's name) parameter. Does not return anything.
If item name cannot be found, output this message: Item not found in cart. Nothing removed.
Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything.
If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart.
If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified.
getNumItemsInCart() (2 pts)
Returns quantity of all items in cart. Has no parameters.
getCostOfCart() (2 pts)
Determines and returns the total cost of items in cart. Has no parameters.
Outputs total of objects in cart.
If cart is empty, output this message: SHOPPING CART IS EMPTY
Outputs each item's description.
The 1st error I get is this: (Please see the attachments for images)Test that getCostOfCart() returns 9 (ShoppingCart)
getCostOfCart() incorrectly returned 3
The 2nd error I get seems to be a spacing error. (Images) I don't believe that it is though. I think it maybe something else causing the issue. But I can not figure it out.
Here is my code:
I hope i explained everything well enough. I apologize for any confusion.