Question: Please provide the necessary c++ code based on the given UML, main, and instructions. Output is also given. Thank you! #include #include #include CartItem.h using

Please provide the necessary c++ code based on the given UML, main, and instructions. Output is also given. Thank you!

Please provide the necessary c++ code based on the given UML, main,and instructions. Output is also given. Thank you! #include #include #include "CartItem.h"

#include

#include

#include "CartItem.h"

using namespace std;

int main()

{

//Code to Test CartItem Class

// Change the following to print your name

// ******************************

cout

cout

string itemName;

double costPerItem;

int qty;

cout

cout

cin >> itemName;

cout

cin >> qty;

cout

cin >> costPerItem;

cout

// Create an object called firstItem and use the constuctor

// that has formal parameters. Pass in the values the

// user typed in

// ***************************

CartItem secondItem("eggs", 1.29, 3);

CartItem thirdItem("Doritos", 4.59, 2);

cout

// Call the displayCartItem method (in the class) three times

// Use the three objects that were created

// **********************************

cout

cout

cin >> qty;

cout

cin >> costPerItem;

// Change the quantity and cost per item of firstItem

// Use the values that the user just typed

// *********************************

cout

// Call the displayCartItem method in the class three times

// Use the three objects that were created

// **********************************

cout

cout

cout

cout

itemName = secondItem.getItem();

costPerItem = secondItem.getPrice();

qty = secondItem.getQuantity();

cout

cout

cout

cout

// Notice - there is no way to change the Item name - so the only way to give an item a

// name is using the constructor - why do you think it is set up this way

system("pause");

}

Constructor One of the constructors assigns the fields the values of the formal parameters. The other does nothing, but-item: string there has to be a no argument CartItem quantity: int rice: double -p +CartItem(item:String, price double, qty:int) +CartItem() constructor Mutators Sets the appropriate fields to the values passed in getItem):String getPriceO:double Accessors Returns the appropriate fields +getQuantityO:int +setPrice(price.double):void +setQuantity(qty:int) :void displayCartItem Displays the cart item as shown on the output. It displays the item, quantity, price, and total cost for the item. setItem( item:String. price:double, qty int)void +displayCartItemO:void Constructor One of the constructors assigns the fields the values of the formal parameters. The other does nothing, but-item: string there has to be a no argument CartItem quantity: int rice: double -p +CartItem(item:String, price double, qty:int) +CartItem() constructor Mutators Sets the appropriate fields to the values passed in getItem):String getPriceO:double Accessors Returns the appropriate fields +getQuantityO:int +setPrice(price.double):void +setQuantity(qty:int) :void displayCartItem Displays the cart item as shown on the output. It displays the item, quantity, price, and total cost for the item. setItem( item:String. price:double, qty int)void +displayCartItemO:void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!