1212 Lab Program Online Shopping Cart Continued Python 3

7.26 LAB*: Program: Online shopping cart (Part 2)

This program extends the earlier "Online shopping cart" program.(Consider first saving your earlier program).

(1) Extend the ItemToPurchase class to contain a new attribute.(2 pts)

  • item_description (string) - Set to "none" in defaultconstructor

Implement the following method for the ItemToPurchase class.

  • print_item_description() - Prints item_description attributefor an ItemToPurchase object. Has an ItemToPurchase parameter.


Ex. of print_item_description() output:

Bottled Water: Deer Park, 12 oz.

(2) Build the ShoppingCart class with the following dataattributes 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 anddate as parameters (2 pts)
  • Attributes
    • customer_name (string) - Initialized in default constructor to"none"
    • current_date (string) - Initialized in default constructor to"January 1, 2016"
    • cart_items (list)
  • Methods
    • add_item()
      • Adds an item to cart_items list. Has parameter ItemToPurchase.Does not return anything.
    • remove_item()
      • Removes item from cart_items list. Has a string (an item'sname) parameter. Does not return anything.
      • If item name cannot be found, output this message: Item notfound in cart. Nothing removed.
    • modify_item()
      • Modifies an item's quantity. Has parameter ItemToPurchase. Doesnot return anything.
      • If item can be found (by name) in cart, modify item incart.
      • If item cannot be found (by name) in cart, output this message:Item not found in cart. Nothing modified.
    • get_num_items_in_cart() (2 pts)
      • Returns quantity of all items in cart. Has no parameters.
    • get_cost_of_cart() (2 pts)
      • Determines and returns the total cost of items in cart. Has noparameters.
    • print_total()
      • Outputs total of objects in cart.
      • If cart is empty, output this message: SHOPPING CART ISEMPTY
    • print_descriptions()
      • Outputs each item's description.

Ex. of print_total() output:

John Doe's Shopping Cart - February 1, 2016Number of Items: 8Nike Romaleos 2 @ $189 = $378Chocolate Chips 5 @ $3 = $15Powerbeats 2 Headphones 1 @ $128 = $128Total: $521


Ex. of print_descriptions() output:

John Doe's Shopping Cart - February 1, 2016Item DescriptionsNike Romaleos: Volt color, Weightlifting shoesChocolate Chips: Semi-sweetPowerbeats 2 Headphones: Bluetooth headphones

(3) In main section of your code, prompt the user for a customer'sname and today's date. Output the name and date. Create an objectof type ShoppingCart. (1 pt)

Ex.

Enter customer's name:John DoeEnter today's date:February 1, 2016Customer name: John DoeToday's date: February 1, 2016


(4) In the main section of your code, implement the print_menu()function. print_menu() has a ShoppingCart parameter, and outputs amenu of options to manipulate the shopping cart. Each option isrepresented by a single character. Build and output the menu withinthe function.

If the an invalid character is entered, continue to prompt for avalid choice. Hint: Implement Quit before implementing otheroptions. Call print_menu() in the main() function. Continue toexecute the menu until the user enters q to Quit. (3 pts)

Ex:

MENUa - Add item to cartr - Remove item from cartc - Change item quantityi - Output items' descriptionso - Output shopping cartq - QuitChoose an option:

(5) Implement Output shopping cart menu option. (3 pts)

Ex:

OUTPUT SHOPPING CARTJohn Doe's Shopping Cart - February 1, 2016Number of Items: 8Nike Romaleos 2 @ $189 = $378Chocolate Chips 5 @ $3 = $15Powerbeats 2 Headphones 1 @ $128 = $128Total: $521

(6) Implement Output item's description menu option. (2 pts)

Ex.

OUTPUT ITEMS' DESCRIPTIONSJohn Doe's Shopping Cart - February 1, 2016Item DescriptionsNike Romaleos: Volt color, Weightlifting shoesChocolate Chips: Semi-sweetPowerbeats 2 Headphones: Bluetooth headphones

(7) Implement Add item to cart menu option. (3 pts)

Ex:

ADD ITEM TO CARTEnter the item name:Nike RomaleosEnter the item description:Volt color, Weightlifting shoesEnter the item price:189Enter the item quantity:2

(8) Implement remove item menu option. (4 pts)

Ex:

REMOVE ITEM FROM CARTEnter name of item to remove:Chocolate Chips

(9) Implement Change item quantity menu option. Hint: Make newItemToPurchase object before using ModifyItem() method. (5pts)

Ex:

CHANGE ITEM QUANTITYEnter the item name:Nike RomaleosEnter the new quantity:3

of the att hus X + • Content 4 x zy 7.26. LAB: Program: Online shox In Python Please 7.26 LAB: Pro C l earn.zybooks.com/zybo . Content 4 x zy 7.26. LAB: Program: Online shox In Python Please 7.26 LAB: Pro X + C l earn.zybooks.com/zybook/UCONNCSE1010

of the att hus X + • Content 4 x zy 7.26. LAB": Program: Online shox In Python Please 7.26 LAB: Pro C l earn.zybooks.com/zybook/UCONNCSE1010Storrs Spring 2020/chapter/7/section/26 Wo My library > CSE 1010: Introduction to Computing for Engineers home > = zyBooks = y ooN 7.26: LAB* Program: Online shopping cart (Part 2) ZyBooks catalog Help/FAQ Junyu Liu - 12: Compare output A 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 Chocolate Chips Semi-sweet Input Powerbeats 2 Headphones Bluetooth headphones 128 Thermos Stainless Steel King Choose an option: ADD ITEM TO CART- Enter the item name: . Content 4 x zy 7.26. LAB": Program: Online shox In Python Please 7.26 LAB: Pro X + C l earn.zybooks.com/zybook/UCONNCSE1010Storrs Spring 2020/chapter/7/section/26 ZyBooks catalog Help/FAQ Junyu Liu - = zyBooks Wo My library > CSE 1010: Introduction to Computing for Engineers home > Boos 7.26: LAB*: Program: Online shopping cart (Part 2) Choose an option: ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU- a - Add item to cart r - Remove item from cart- C - Change item quantity- i - Output items' descriptions- 0 - Output shopping cart- 9 - Quite Choose an option: ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU- a - Add item to cart r - Remove item from cart- C - Change item quantity i - Output items' descriptions 0 - Output shopping cart- 9 - Quit- Your outnut ends Show transcribed image text of the att hus X + • Content 4 x zy 7.26. LAB": Program: Online shox In Python Please 7.26 LAB: Pro C l earn.zybooks.com/zybook/UCONNCSE1010Storrs Spring 2020/chapter/7/section/26 Wo My library > CSE 1010: Introduction to Computing for Engineers home > = zyBooks = y ooN 7.26: LAB* Program: Online shopping cart (Part 2) ZyBooks catalog Help/FAQ Junyu Liu - 12: Compare output A 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 Chocolate Chips Semi-sweet Input Powerbeats 2 Headphones Bluetooth headphones 128 Thermos Stainless Steel King Choose an option: ADD ITEM TO CART- Enter the item name:
. Content 4 x zy 7.26. LAB": Program: Online shox In Python Please 7.26 LAB: Pro X + C l earn.zybooks.com/zybook/UCONNCSE1010Storrs Spring 2020/chapter/7/section/26 ZyBooks catalog Help/FAQ Junyu Liu - = zyBooks Wo My library > CSE 1010: Introduction to Computing for Engineers home > Boos 7.26: LAB*: Program: Online shopping cart (Part 2) Choose an option: ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU- a - Add item to cart r - Remove item from cart- C - Change item quantity- i - Output items' descriptions- 0 - Output shopping cart- 9 - Quite Choose an option: ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU- a - Add item to cart r - Remove item from cart- C - Change item quantity i - Output items' descriptions 0 - Output shopping cart- 9 - Quit- Your outnut ends

medeirostherembeens.blogspot.com

Source: https://www.viewassignment.com/ExpertAnswers/7-26-lab-program-online-shopping-cart-part-2-this-program-extends-the-earlier-online-shopping-cart-p

0 Response to "1212 Lab Program Online Shopping Cart Continued Python 3"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel