Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7 . 2 2 Main Lab 7 - Online shopping cart Background This main lab extends the earlier prep lab Online shopping cart Part 1

7.22 Main Lab 7- Online shopping cart Background This main lab extends the earlier prep lab "Online shopping cart Part 1".(You should save this as a separate project from the earlier prep lab). You will create an on-line shopping cart like you might use for your on-line purchases. The goal is to become comfortable with setting up classes and using objects. Requirements This lab can be done individually or as pair programming. Expanded ItemToPurchase Class Extend the ItemToPurchase class from the Prep Lab (you may copy and paste your code) as follows. We will not do unit testing in this lab so we will not be giving you the names of the member functions. Create good ones on your own. Additional Private data members a string for the description of the item Create a parameterized constructor to assign item name, item description, item price, and item quantity If arguments are not provided, use default values of "none" for name and description, and 0 for price and quantity Additional public member functions Set an item description Get an item description Print the cost of an item - Prints the item name followed by the quantity, price, and subtotal (see example) Print the description of an item - Prints the item name and description (see example) Example output of the function which prints the cost of an item: Bottled Water 10 @ $1.50= $15.00 Example output of the function which prints the item description: Bottled Water: Deer Park, 12 oz. ShoppingCart Class Create three new files - Name all your files exactly as specified as that is required for zyBook file submission. ShoppingCart.h - Class declaration ShoppingCart.cpp - Class definition main.cpp - main function (main's functionality will differ significantly from that of the prep lab) Build the ShoppingCart class with the following specifications. Note: Some functions can be function stubs (empty functions) initially, to be completed in later steps. Also, we usually declare all variable at the top of the code block. Note that you could be declaring some class objects after receiving user input, so that is a case where it would be all right to declare a variable later in your code. Private data members Name of the customer Date the cart was created Vector of items objects Parameterized constructor which takes the customer name and date as parameters If arguments are not provided, use default values of "none" for the name and "January 1,2016" for the date Must have the following public member functions Get the name of the customer Get the date the cart was created Add an item object to the cart vector. Accepts a new item object as a parameter. If item name is already found in the cart, prints this message: "Item is already found in the cart. It will not be added." Remove an item object from the cart. Accepts an item name as a parameter. If item name cannot be found, prints this message: "Item not found in cart. It will not be removed." Update the quantity of an item object in the cart If item name cannot be found, prints this message: "Item not found in cart. It will not be modified." If the quantity is set to 0, still leave the item in the cart, but treat it as a 0 in all counts, etc. Return the quantity of items in the cart Return the total cost of all items in the cart Print the description of each item in the cart If cart is empty, prints this message: "Shopping cart is empty." Print the total number and cost of items in the cart If cart is empty, prints this message: "Shopping cart is empty." Example output of the function which prints the item 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 Example output of the function which prints the number and costs of items in the cart: John Doe's Shopping Cart - February 1,2016 Number of Items: 8 Nike Romaleos 2 @ $189.00= $378.00 Chocolate Chips 5 @ $3.50= $17.50 Powerbeats 2 Headphones 1 @ $128.00= $128.00 Total: $523.50 You may also create private helper functions in the ShoppingCart class if you'd like. Hint: A function to find if and where an item name resides in the cart could be helpful in multiple places. Main Function Options Menu A template for the main.cpp file is given to you. You can download the template to view it from the same area you will upload your code in. In your project in your IDE, you should create a new file using the normal process and copy-paste the contents of the template into that file. This template should remove some of the tedium of making sure your input and output matches exactly what is expected, however you are free to start from scratch on your own if you desire. If you do want to start from scratch, pay careful attention to this section of the spec. See the full input/output example below to know the expected format. In main, first prompt the user for a customer's name and today's date. Create an object of type Shopping

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

Students also viewed these Databases questions