Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ plz , And please make sure all results are when apply these examples! 7.22 LAB*: Program: Online shopping cart (Part 2) This program extends

C++ plz , And please make sure all results are when apply these examples!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

7.22 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 per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0) (1 pt) Public member functions o SetDescription() mutator & GetDescription accessor (2 pts) o PrintitemCost-Outputs the item name followed by the quantity, price, and subtotal o Printitem Description() - Outputs the item name and description Private data members o string item Description - Initialized in default constructor to "none" Ex. of PrintitemCost output: Bottled Water 10 @ $1 = $10 Ex. of Printitem Description() output: Bottled Water: Deer Park, 12 oz. (2) Create three new files: Shopping Cart.h - Class declaration Shopping Cart.cpp-Class definition main.cpp- main function (Note: main()'s functionality differs from the warm up) Build the Shopping Cart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be completed in later steps. Default constructor Parameterized constructor which takes the customer name and date as parameters (1 pt) Private data members o string customerName - Initialized in default constructor to "none" o string currentDate - Initialized in default constructor to January 1, 2016" o vector cartitems Public member functions o GetCustomerName) accessor (1 pt) o GetDate() accessor (1 pt) o Additem Adds an item to cartitems vector. Has parameter Item To Purchase. Does not return anything. o Removeitem Removes item from cartitems vector. 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. o Modifyltemo Modifies an item's description, price, and/or quantity. Has parameter Item To Purchase. 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. o GetNumitemsInCart0 (2 pts) Returns quantity of all items in cart. Has no parameters. o GetCostOfCarto (2 pts) Determines and returns the total cost of items in cart. Has no parameters. o Print Total Outputs total of objects in cart. If cart is empty, output this message: SHOPPING CART IS EMPTY o PrintDescriptions Outputs each item's description. Ex. of PrintTotal output: John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $521 Ex. of Print Descriptions() output: John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (3) In main, prompt the user for a customer's name and today's date. Output the name and date. Create an object of type Shopping Cart (1 pt) EX Enter customer's name: John Doe Enter today's date: February 1, 2016 Customer name: John Doe Today's date: February 1, 2016 (4) Implement the PrintMenu() function. PrintMenu() has a Shopping Cart 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 the 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. (3 pts) EX MENU a - Add item to cart d - Remove item from cart c - Change item quantity i Output items! descriptions 0 - Output shopping cart - Quit Choose an option: (5) Implement Output shopping cart menu option. (3 pts) Ex: OUTPUT SHOPPING CART John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones i @ $128 = $128 Total: $521 (6) Implement Output item's description menu option. (2 pts) EX OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (7) Implement Add item to cart menu option. (3 pts) Ex: ADD ITEM TO CART Enter the item name: Nike Romaleos Enter the item description: Volt color, Weightlifting shoes Enter the item price: 189 Enter the item quantity: 2 (8) Implement remove item menu option. (4 pts) Ex: REMOVE ITEM FROM CART Enter name of item to remove: Chocolate Chips (9) Implement Change item quantity menu option. Hint: Make new Item ToPurchase object and use Item To Purchase modifiers before using Modify/tem() function. (5 pts) Ex: CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3 1: Unit test 1/1 Tests that ItemToPurchase("Bottled Water", "Deer Park, 12 oz.", 1, 10) correctly initializes item Test feedback Item properly initialized. 2: Unit test 2/2 Tests item.setDescription("Volt color, Weightlifting shoes") and item.GetDescription() == "Volt color, Weightlifting shoes" (ItemToPurchase) Test feedback Item description "Volt color, Weightlifting shoes" correctly set and i 3: Unit test 0/2 Tests default constructor and accessors (ShoppingCart) Shopping Cart improperly initialized with default constructor. Test feedback GetCustomerName () returns none GetDate() returns none 4: Unit test 1/1 Tests Shopping Cart("John Doe", "February 1, 2016") correctly initializes cart Test feedback Shopping Cart correctly initialized. 5: Unit test 2/2 Tests that GetNumitemsInCart() returns 6 (Shopping Cart) Test feedback GetNumItems InCart() correctly returns 6 6: Unit test 2/2 Test that GetCostOfCart() returns 10 (Shopping Cart) Test feedback GetcostofCart() correctly returns 10 7: Compare output 1/1 Input John Doe February 1, 2016 a Enter customer's name: Enter today's date: Your output correctly starts with Customer name: John Doe Today's date: February 1, 2016 8: Compare output ^ 3/3 John Doe February 1, 2016 f Input 3 a Enter customer's name: Enter today's date: Customer name: John Doe Today's date: February 1, 2016 MENU a Your output Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart 9 - Quit i Choose an option: Choose an option: Choose an option: 9: Compare output ^ 3/3 John Doe February 1, 2016 Input a OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 0 February 1, 2016 SHOPPING CART IS EMPTY Total: $0 Your output correctly ends with MENU a Add item to cart i Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit a Choose an option: 10: Compare output ^ 3/3 John Doe February 1, 2016 a Input Nike Romaleos Volt color, Weightlifting shoes 189 2 9 ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU rod 0 + C - Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i - a Your output correctly ends with Choose an option: OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 2 February 1, 2016 Nike Romaleos 2 @ $189 = $378 Total: $378 MENU c Add item to cart Remove item from cart Change item quantity i - Output items' descriptions Output shopping cart 9 - Quit 0 - Choose an option: 11: Compare output ^ 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 Input 2 Spectre DVD a REMOVE ITEM FROM CART Enter name of item to remove: a Your output ends with Item not found in cart. Nothing removed. MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i 0 Choose an option: REMOVE ITEM FROM CART Enter name of item to remove: Item not found in cart. Nothing removed.d a Expected output ends with MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart a Quit i - o Choose an option: 12: Compare output ^ 2/2 John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 Chocolate Chips Input Semi-sweet 3 5 a Powerbeats 2 Headphones Bluetooth headphones 128 1 Chocolate Chips 0 0 REMOVE ITEM FROM CART Enter name of item to remove: MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i a Choose an option: OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 3 February 1, 2016 Your output correctly ends with Nike Romaleos 2 @ $189 = $378 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $506 MENU a Add item to cart i Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit a Choose an option: 13: Compare output 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 a Chocolate Chips Semi-sweet 3 5 Input a Powerbeats 2 Headphones Bluetooth headphones 128 1 Thermos Stainless Steel King 5 CHANGE ITEM QUANTITY Enter the item name: Enter the new quantity: Item not found in cart. Nothing modified. Expected output ends with MENU Add item to cart d Remove item from cart Change item quantity i Output items' descriptions Output shopping cart 9 - Quit Choose an option: 14: Compare output 3/3 John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 a Chocolate Chips Semi-sweet 3 5 Input a Powerbeats 2 Headphones Bluetooth headphones 128 1 Nike Romaleos 3 OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items: 9 February 1, 2016 Nike Romaleos 3 @ $189 = $567 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones i @ $128 = $128 Total: $710 Your output correctly ends with a MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart q - Quit i Choose an option: 15: Compare output ^ 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 a Nike Romaleos Volt color, Weightlifting shoes 189 2 Input Chocolate Chips Semi-sweet 3 5 a Powerbeats 2 Headphones Bluetooth headphones 128 1 i a OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart February 1, 2016- Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones Expected output ends with MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart a Quit i Choose an option: Feedback? 7.22 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 per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0) (1 pt) Public member functions o SetDescription() mutator & GetDescription accessor (2 pts) o PrintitemCost-Outputs the item name followed by the quantity, price, and subtotal o Printitem Description() - Outputs the item name and description Private data members o string item Description - Initialized in default constructor to "none" Ex. of PrintitemCost output: Bottled Water 10 @ $1 = $10 Ex. of Printitem Description() output: Bottled Water: Deer Park, 12 oz. (2) Create three new files: Shopping Cart.h - Class declaration Shopping Cart.cpp-Class definition main.cpp- main function (Note: main()'s functionality differs from the warm up) Build the Shopping Cart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be completed in later steps. Default constructor Parameterized constructor which takes the customer name and date as parameters (1 pt) Private data members o string customerName - Initialized in default constructor to "none" o string currentDate - Initialized in default constructor to January 1, 2016" o vector cartitems Public member functions o GetCustomerName) accessor (1 pt) o GetDate() accessor (1 pt) o Additem Adds an item to cartitems vector. Has parameter Item To Purchase. Does not return anything. o Removeitem Removes item from cartitems vector. 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. o Modifyltemo Modifies an item's description, price, and/or quantity. Has parameter Item To Purchase. 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. o GetNumitemsInCart0 (2 pts) Returns quantity of all items in cart. Has no parameters. o GetCostOfCarto (2 pts) Determines and returns the total cost of items in cart. Has no parameters. o Print Total Outputs total of objects in cart. If cart is empty, output this message: SHOPPING CART IS EMPTY o PrintDescriptions Outputs each item's description. Ex. of PrintTotal output: John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $521 Ex. of Print Descriptions() output: John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (3) In main, prompt the user for a customer's name and today's date. Output the name and date. Create an object of type Shopping Cart (1 pt) EX Enter customer's name: John Doe Enter today's date: February 1, 2016 Customer name: John Doe Today's date: February 1, 2016 (4) Implement the PrintMenu() function. PrintMenu() has a Shopping Cart 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 the 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. (3 pts) EX MENU a - Add item to cart d - Remove item from cart c - Change item quantity i Output items! descriptions 0 - Output shopping cart - Quit Choose an option: (5) Implement Output shopping cart menu option. (3 pts) Ex: OUTPUT SHOPPING CART John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones i @ $128 = $128 Total: $521 (6) Implement Output item's description menu option. (2 pts) EX OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones (7) Implement Add item to cart menu option. (3 pts) Ex: ADD ITEM TO CART Enter the item name: Nike Romaleos Enter the item description: Volt color, Weightlifting shoes Enter the item price: 189 Enter the item quantity: 2 (8) Implement remove item menu option. (4 pts) Ex: REMOVE ITEM FROM CART Enter name of item to remove: Chocolate Chips (9) Implement Change item quantity menu option. Hint: Make new Item ToPurchase object and use Item To Purchase modifiers before using Modify/tem() function. (5 pts) Ex: CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3 1: Unit test 1/1 Tests that ItemToPurchase("Bottled Water", "Deer Park, 12 oz.", 1, 10) correctly initializes item Test feedback Item properly initialized. 2: Unit test 2/2 Tests item.setDescription("Volt color, Weightlifting shoes") and item.GetDescription() == "Volt color, Weightlifting shoes" (ItemToPurchase) Test feedback Item description "Volt color, Weightlifting shoes" correctly set and i 3: Unit test 0/2 Tests default constructor and accessors (ShoppingCart) Shopping Cart improperly initialized with default constructor. Test feedback GetCustomerName () returns none GetDate() returns none 4: Unit test 1/1 Tests Shopping Cart("John Doe", "February 1, 2016") correctly initializes cart Test feedback Shopping Cart correctly initialized. 5: Unit test 2/2 Tests that GetNumitemsInCart() returns 6 (Shopping Cart) Test feedback GetNumItems InCart() correctly returns 6 6: Unit test 2/2 Test that GetCostOfCart() returns 10 (Shopping Cart) Test feedback GetcostofCart() correctly returns 10 7: Compare output 1/1 Input John Doe February 1, 2016 a Enter customer's name: Enter today's date: Your output correctly starts with Customer name: John Doe Today's date: February 1, 2016 8: Compare output ^ 3/3 John Doe February 1, 2016 f Input 3 a Enter customer's name: Enter today's date: Customer name: John Doe Today's date: February 1, 2016 MENU a Your output Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart 9 - Quit i Choose an option: Choose an option: Choose an option: 9: Compare output ^ 3/3 John Doe February 1, 2016 Input a OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 0 February 1, 2016 SHOPPING CART IS EMPTY Total: $0 Your output correctly ends with MENU a Add item to cart i Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit a Choose an option: 10: Compare output ^ 3/3 John Doe February 1, 2016 a Input Nike Romaleos Volt color, Weightlifting shoes 189 2 9 ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU rod 0 + C - Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i - a Your output correctly ends with Choose an option: OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 2 February 1, 2016 Nike Romaleos 2 @ $189 = $378 Total: $378 MENU c Add item to cart Remove item from cart Change item quantity i - Output items' descriptions Output shopping cart 9 - Quit 0 - Choose an option: 11: Compare output ^ 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 Input 2 Spectre DVD a REMOVE ITEM FROM CART Enter name of item to remove: a Your output ends with Item not found in cart. Nothing removed. MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i 0 Choose an option: REMOVE ITEM FROM CART Enter name of item to remove: Item not found in cart. Nothing removed.d a Expected output ends with MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart a Quit i - o Choose an option: 12: Compare output ^ 2/2 John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 Chocolate Chips Input Semi-sweet 3 5 a Powerbeats 2 Headphones Bluetooth headphones 128 1 Chocolate Chips 0 0 REMOVE ITEM FROM CART Enter name of item to remove: MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit i a Choose an option: OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items : 3 February 1, 2016 Your output correctly ends with Nike Romaleos 2 @ $189 = $378 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $506 MENU a Add item to cart i Remove item from cart Change item quantity Output items' descriptions Output shopping cart Quit a Choose an option: 13: Compare output 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 a Chocolate Chips Semi-sweet 3 5 Input a Powerbeats 2 Headphones Bluetooth headphones 128 1 Thermos Stainless Steel King 5 CHANGE ITEM QUANTITY Enter the item name: Enter the new quantity: Item not found in cart. Nothing modified. Expected output ends with MENU Add item to cart d Remove item from cart Change item quantity i Output items' descriptions Output shopping cart 9 - Quit Choose an option: 14: Compare output 3/3 John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 2 a Chocolate Chips Semi-sweet 3 5 Input a Powerbeats 2 Headphones Bluetooth headphones 128 1 Nike Romaleos 3 OUTPUT SHOPPING CART John Doe's Shopping Cart Number of Items: 9 February 1, 2016 Nike Romaleos 3 @ $189 = $567 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones i @ $128 = $128 Total: $710 Your output correctly ends with a MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart q - Quit i Choose an option: 15: Compare output ^ 0/2 Output differs. See highlights below. Special character legend John Doe February 1, 2016 a Nike Romaleos Volt color, Weightlifting shoes 189 2 Input Chocolate Chips Semi-sweet 3 5 a Powerbeats 2 Headphones Bluetooth headphones 128 1 i a OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart February 1, 2016- Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats 2 Headphones: Bluetooth headphones Expected output ends with MENU Add item to cart Remove item from cart Change item quantity Output items' descriptions Output shopping cart a Quit i Choose an option: Feedback

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago