Question: Module 6 : Portfolio Milestone Step 4 : Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method
Module : Portfolio Milestone
Step : Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs empty methods initially, to be completed in later steps
Parameterized constructor, which takes the customer name and date as parameters
Attributes
customername string Initialized in default constructor to "none"
currentdate string Initialized in default constructor to "January
cartitems list
Methods
additem
o Adds an item to cartitems list. Has parameter ItemToPurchase. Does not return anything.
removeitem
o Removes item from cartitems list. Has a string an item's name parameter. Does not return anything.
o If item name cannot be found, output this message: Item not found in cart. Nothing removed.
modifyitem
o Modifies an item's description, price, andor quantity. Has parameter ItemToPurchase. Does not return anything.
o 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.
o If item cannot be found by name in cart, output this message: Item not found in cart. Nothing modified.
getnumitemsincart
o Returns quantity of all items in cart. Has no parameters.
getcostofcart
o Determines and returns the total cost of items in cart. Has no parameters.
printtotal
o Outputs total of objects in cart.
o If cart is empty, output this message: SHOPPING CART IS EMPTY
printdescriptions
o Outputs each item's description.
Step : In the main section of your code, implement the printmenu function. printmenu has a ShoppingCart parameter and outputs a menu of options to manipulate the shopping cart. Each option is represented by a single character. Build and output the menu within the function.
If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call printmenu in the main function. Continue to execute the menu until the user enters q to Quit.
Step : Implement Output shopping cart menu option. Implement Output item's description menu option.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
