Here is my code from part 1. The below directions are an extension of it:  #include using namespace std; #include "ItemToPurchase.h" int main(){ string s; int p,q; ItemToPurchase item1; ItemToPurchase item2; cout<<"Item 1"<>p; cout<<"Enter Item Quantity :"<>q; item1.SetName(s); item1.SetPrice(p); item1.SetQuantity(q); cin.ignore(); cout<<"Item 2"<>p; cout<<"Enter Item Quantity :"<>q; item2.SetName(s); item2.SetPrice(p); item2.SetQuantity(q); cout<<"TOTAL COST: "< cartItems Public member functions GetCustomerName() accessor  GetDate() accessor  AddItem() Adds an item to cartItems vector. Has parameter ItemToPurchase. Does not return anything. 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. ModifyItem() 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. GetNumItemsInCart() Returns quantity of all items in cart. Has no parameters. GetCostOfCart() 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 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 (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 ShoppingCart.  (4) Implement the PrintMenu() function in main.cpp to print the following menu of options to manipulate the shopping cart.  (5) Implement the ExecuteMenu() function in main.cpp that takes 2 parameters: a character representing the user's choice and the reference of a shopping cart. ExecuteMenu() performs the menu options described below, according to the user's choice.  (6) In main(), call PrintMenu() and prompt for the user's choice of menu options. Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling ExecuteMenu(). Then, print the menu and prompt for a new option. Continue until the user enters 'q'. Hint: Implement Quit before implementing other options. (7) Implement Output shopping cart menu option in ExecuteMenu(). ( (8) Implement Output item's description menu option in ExecuteMenu().  (9) Implement Add item to cart menu option in ExecuteMenu().  (10) Implement remove item menu option in ExecuteMenu(). (11) Implement Change item quantity menu option in ExecuteMenu(). Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using ModifyItem() function.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Here is my code from part 1. The below directions are an extension of it: 

#include <iostream>
using namespace std;
#include "ItemToPurchase.h"

int main(){

string s;
int p,q;
ItemToPurchase item1;
ItemToPurchase item2;

cout<<"Item 1"<<endl;
cout<<"Enter Item Name :"<<endl;
getline(cin,s);
cout<<"Enter Item Price :"<<endl;
cin>>p;
cout<<"Enter Item Quantity :"<<endl;
cin>>q;
item1.SetName(s);
item1.SetPrice(p);
item1.SetQuantity(q);
cin.ignore();

cout<<"Item 2"<<endl;
cout<<"Enter Item Name :"<<endl;
getline(cin,s);
cout<<"Enter Item Price :"<<endl;
cin>>p;
cout<<"Enter Item Quantity :"<<endl;
cin>>q;

item2.SetName(s);
item2.SetPrice(p);
item2.SetQuantity(q);
cout<<"TOTAL COST: "<<endl;
cout<<item1.GetName()<<" "<<item1.GetQuantity()<<" @ $"<<item1.GetPrice()<<" = $"<<(item1.GetQuantity()*item1.GetPrice()) <<endl;
cout<<item2.GetName()<<" "<<item2.GetQuantity()<<" @ $"<<item2.GetPrice()<<" = $"<<(item2.GetQuantity()*item2.GetPrice())<<endl;
cout<<"TOTAL : $"<<(item1.GetQuantity()*item1.GetPrice())+(item2.GetQuantity()*item2.GetPrice())<<endl;

return 0;
}

Part 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 & GetDescription() accessor 
    • PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal
    • PrintItemDescription() - Outputs the item name and description
  • Private data members
    • string itemDescription - Initialized in default constructor to "none"

Ex. of PrintItemCost() output:

Bottled Water 10 @ $1 = $10

Ex. of PrintItemDescription() output:

Bottled Water: Deer Park, 12 oz.


(2) Create three new files:

  • ShoppingCart.h - Class declaration
  • ShoppingCart.cpp - Class definition
  • main.cpp - main() function (Note: main()'s functionality differs from the warm up)

Build the ShoppingCart 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 
  • Private data members
    • string customerName - Initialized in default constructor to "none"
    • string currentDate - Initialized in default constructor to "January 1, 2016"
    • vector < ItemToPurchase > cartItems
  • Public member functions
    • GetCustomerName() accessor 
    • GetDate() accessor 
    • AddItem()
      • Adds an item to cartItems vector. Has parameter ItemToPurchase. Does not return anything.
    • 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.
    • ModifyItem()
      • 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.
      • GetNumItemsInCart()
        • Returns quantity of all items in cart. Has no parameters.
    • GetCostOfCart()
      • 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
    • 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

(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 ShoppingCart. 


(4) Implement the PrintMenu() function in main.cpp to print the following menu of options to manipulate the shopping cart. 


(5) Implement the ExecuteMenu() function in main.cpp that takes 2 parameters: a character representing the user's choice and the reference of a shopping cart. ExecuteMenu() performs the menu options described below, according to the user's choice. 


(6) In main(), call PrintMenu() and prompt for the user's choice of menu options. Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling ExecuteMenu(). Then, print the menu and prompt for a new option. Continue until the user enters 'q'. Hint: Implement Quit before implementing other options.

(7) Implement Output shopping cart menu option in ExecuteMenu(). (

(8) Implement Output item's description menu option in ExecuteMenu(). 


(9) Implement Add item to cart menu option in ExecuteMenu(). 

(10) Implement remove item menu option in ExecuteMenu().


(11) Implement Change item quantity menu option in ExecuteMenu(). Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using ModifyItem() function.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 9 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education