
Concept explainers
Create three files:
- ItemToPurchase.h - Class declaration
- ItemToPurchase.cpp - Class definition
- main.cpp - main() function
Build the ItemToPurchase class with the following specifications:
- Default constructor
- Public class functions (mutators & accessors)
- setName() & name()
- setPrice() & price()
- setQuantity() & quantity()
- 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
- printItemCost() - Outputs the item name followed by the quantity, price, and subtotal
- printItemDescription() - Outputs the item name and description
- Private data members
- string _description - 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.
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.
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.
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.
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.
(Step 9 ) implement remove item menu option
ex:
REMOVE ITEM FROM CART
Enter name of item to remove:
Chocolate Chips

Step by stepSolved in 3 steps with 1 images

- When a class contains a data member that is a pointer to dynamically-allocated storage, which of the following member functions should be implemented? All three of the member functions listed below should be implemented. The copy assignment operator. The copy constructor. The destructor.arrow_forwardplease assist me C++ language you are the owner of a pet store and you want to create a database of the different types of pets you sell you will create a base class called Pet and will include the following member variables: gender size (small, medium, or large) trained (yes or no) age long haired (yes or no) create two constructors default will initialize member variable with blanks or zeros second constructor will assign parameter values to each variable create your mutator functions create your accessor functions and save your Pet.h file create a new header file for dogs: dog.h it will be a derived class of Pet.h it will inherit the public functions of Pet.h it will have its own member variable breed (ie: beagle, collie, etc.) create the .cpp file, pet store create two instances of dog use the default constructor for the first dog use the second constructor for the second dog display both dog's data labeling each line report should look something like this…arrow_forwardUsing C# language: Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming methodologies. Design a class named Contractor. The class should keep the following information: Contractor name Contractor number Contractor start date Write one or more constructors and the appropriate accessor and mutator functions for the class.arrow_forward
- Double Bubble For this exercise you need to create a Bubble class and construct two instances of the Bubble object. You will then take the two Bubble objects and combine them to create a new, larger combined Bubble object. This will be done using functions that take in these Bubble objects as parameters. The Bubble class contains one data member, radius_, and the corresponding accessor and mutator methods for radius_, GetRadius and SetRadius. Create a member function called CalculateVolume that computes for the volume of a bubble (sphere). Use the value 3.1415 for PI. Your main function has some skeleton code that asks the user for the radius of two bubbles. You will use this to create the two Bubble objects. You will create a CombineBubbles function that receives two references (two Bubble objects) and returns a Bubble object. Combining bubbles simply means creating a new Bubble object whose radius is the sum of the two Bubble objects' radii. Take note that the CombineBubbles function…arrow_forwardTwo data members: feet(int) and inches(float) Two overloaded constructors: one that takes no argument and the other that takes two arguments. Zero argument constructor initializes data members from 0 whereas two argument constructor initializes data members from the passed arguments. Two getters and two setters corresponding to two data members. A member function named toDecimal that converts a distance to decimal, e.g., if a distance equals 2 feet and 6 inches then it would become 2.5 in decimal. A member function named toString that returns a string representation of a distance, e.g., if a distance equals 2 feet and 6 inches then the corresponding string representation should be 2’-6”. by using C++arrow_forwardPersonal Information Class: Design a class called Employee that holds the following data about an employee: name ID number Department Job Title Class. Store your class in a separate file called employee.py. Your class will have an initializer method that will be passed the information entered by the user as arguments. Write appropriate accessor and mutator methods for each data attribute. Write a __str__ method to print the contents of the class (see example of __str__ on p. 523). Main program: Your main program should create three instances of the class. Your program should get the information from the user and pass it as parameters to the initializer method. Using the __str__ method invoked by the print function, the program should display the personal information for the three individuals. Output and Sample Dialog: Enter employee name: Mary Smith Enter employee ID: 123456 Enter department: Accounting Enter position: Accountant Enter employee name: Joe Morales Enter…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





