Create two new files: 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 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 customerName() accessor date() accessor addItem() Adds an item to cart items vector. Has a parameter of type ItemToPurchase. Does not return anything. removeItem() Removes item from cart items vector. Has a parameter of type string (an item's name). 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 a parameter of type ItemToPurchase. Does not return anything. If item can be found (by name) in cart, check if parameter variable has default values for description, price, and/or quantity. For each of the non-default values in parameter, set the item in the cart to the non-default value. For example, if the parameter has non-default values for quantity and price but a default value for the description, then just set the quantity and price in the cart item to the parameter's values for quantity and price and leave the cart item's description alone. If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified. numItemsInCart() Returns quantity of all items in cart. Has no parameters. costOfCart() 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 Ex. of printDescriptions() 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 as global function (non-member 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 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 o - 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 @ $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 modifyItem() function. (5 pts) Ex: CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3

Oh no! Our experts couldn't answer your question.

Don't worry! We won't leave you hanging. Plus, we're giving you back one question for the inconvenience.

Submit your question and receive a step-by-step explanation from our experts in as fast as 30 minutes.
You have no more questions left.
Message from our expert:
Our experts are unable to provide you with a solution at this time. Try rewording your question, and make sure to submit one question at a time. We've credited a question to your account.
Your Question:

Create two new files:

  • 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 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
    • customerName() accessor
    • date() accessor
    • addItem()
      • Adds an item to cart items vector. Has a parameter of type ItemToPurchase. Does not return anything.
    • removeItem()
      • Removes item from cart items vector. Has a parameter of type string (an item's name). 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 a parameter of type ItemToPurchase. Does not return anything.
      • If item can be found (by name) in cart, check if parameter variable has default values for description, price, and/or quantity. For each of the non-default values in parameter, set the item in the cart to the non-default value. For example, if the parameter has non-default values for quantity and price but a default value for the description, then just set the quantity and price in the cart item to the parameter's values for quantity and price and leave the cart item's description alone.
      • If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified.
    • numItemsInCart()
      • Returns quantity of all items in cart. Has no parameters.
    • costOfCart()
      • 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


Ex. of printDescriptions() 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 as global function (non-member 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 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 o - 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 @ $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 modifyItem() function. (5 pts)

Ex:

CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3

Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,