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 6: Portfolio Milestone
Step 4: 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
customer_name (string)- Initialized in default constructor to "none"
current_date (string)- Initialized in default constructor to "January 1,2020"
cart_items (list)
Methods
add_item()
o Adds an item to cart_items list. Has parameter ItemToPurchase. Does not return anything.
remove_item()
o Removes item from cart_items 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.
modify_item()
o Modifies an item's description, price, and/or 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.
get_num_items_in_cart()
o Returns quantity of all items in cart. Has no parameters.
get_cost_of_cart()
o Determines and returns the total cost of items in cart. Has no parameters.
print_total()
o Outputs total of objects in cart.
o If cart is empty, output this message: SHOPPING CART IS EMPTY
print_descriptions()
o Outputs each item's description.
Step 5: In the main section of your code, implement the print_menu() function. print_menu() 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 print_menu() in the main() function. Continue to execute the menu until the user enters q to Quit.
Step 6: 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 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 Programming Questions!