Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ , please add comments and compiler info. (Step 1) Create three files: - ItemToPurchase.h- h-lass declaration - ItemToPurchase.cpp - Class definition - main.cpp
In C++ , please add comments and compiler info.
(Step 1) Create three files: - ItemToPurchase.h- h-lass declaration - ItemToPurchase.cpp - Class definition - main.cpp - main0 function (Until you get to step 4, just use this main.cpp file to unit test your functions outside of zyBooks. Alternatively, you can create a test.cpp file that is only used outside of zyBooks that contains all of your unit tests. In this case, leave the main function in main.cpp blank until you get to step 4.) Build the ItemToPurchase class with the following specifications: - Default constructor - Public class functions (mutators & accessors) - setName() \& name(0 - setPrice() \& price() - setQuantity0 \& quantity0 - Private data members - string _name - Initialized in default constructor to "none" - int_price - Initialized in default constructor to 0 - int_quantity - Initialized in default constructor to 0 (Step 2) 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 ). - Public member functions - setDescription() mutator \& description() accessor - printltemcost 0 - Outputs the item name followed by the quantity, price, and subtotal - print|temDescription() - Outputs the item name and description - Private data members - string _description - Initialized in default constructor to "none" Ex. of printltemCost 0 output: Bottled water 10 o $1=$10 Ex. of printitemDescription( output: Bottled Water: Deer Park, 12 oz. - ShoppingCart.h - Class declaration - ShoppingCart.cpp - Class definition Build the ShoppingCart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be ompleted in later steps. - Default constructor - Parameterized constructor which takes the customer name and date as parameters - Private data members - string _customerName - Initialized in default constructor to "none" - string _currentDate - Initialized in default constructor to "January 1, 2016" - vector __cartltems - Public member functions - customerName0 accessor - date() accessor - additem0 - Adds an item to cartltems vector. Has parameter ItemToPurchase. Does not return anything. - removeltem0 - Removes item from cartltems 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. - modifyltem0 - 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. - numltemsinCart( - Returns quantity of all items in cart. Has no parameters. - costOfCart0 - Determines and returns the total cost of items in cart. Has no parameters. - printTotal() - Outputs total of objects in cart. - If cart is empty, output this message: SHOPPING CART IS EMPTY - printDescriptions0 - 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 e $128=$128 Total: $521 Ex. of printDescriptions0 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 (Step 4) In main(), prompt the user for a customer's name and today's date. Output the name and date. Create an object of type ShoppingCart. Ex. Enter customer's name: John Doe Enter today's date: February 1, 2016 Customer name: John Doe Today's date: February 1, 2016 (Step 5) 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 the an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call printMenu0 in the main0 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 - - output shopping cart q - Quit Choose an option: (Step 6) 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 e $189=$378 Chocolate Chips 5 @ $3=$15 Powerbeats 2 Headphones 1 \& $128=$128 Total: $521 (Step 7) 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 (Step 8) Implement Add item to cart menu option. 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 (Step 9) Implement remove item menu option. Ex: REMOVE ITEM FROM CART Enter name of item to remove: Chocolate Chips (Step 10) Implement Change item quantity menu option. Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using modifyltem0 function. (5 pts) Ex: CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3 Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. \begin{tabular}{c|c|c} main.cpp & ItemToPurchase.cpp & ItemToPurchase.h \\ File added Remove & File added Remove & File added \\ & & Remove \\ \hline \end{tabular} ShoppingCart.h ShoppingCart.cpp File added Remove File added RemoveStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started