Answer to Question #315862 in C++ for amna

Question #315862

You are required to implement a shopping cart module for an online shopping mall. From the available

items a user will select the item to purchase and add this into his shopping cart. Before the checkout

customer can remove any item from the cart at any time.

A single item in the cart contains the following details:

class Item

{

private:

int itemID;

string itemName;

double price;

double purchasedQuantity;

double totalPrice;

public:

//constructors and getter setters

};

For the implementation of the required module you have to meet the following requirements:

2- Customer can remove item or change the quantity at any time.

There are two possibilities:

i. Customer wants to remove the item form the cart

ii. Customer wants to change the quantity of item in the cart


1
Expert's answer
2022-03-22T16:11:24-0400
class Item
{
public:
	Item(string itemName, int price, int purchasedQuantity, int itemId);
	void totalPrice()
	{
		cout << "Total price: " << price * purchasedQuantity << endl;
	}
	
private:
	int itemId;
	string itemName;
	double price;
	double purchasedQuantity;
	double totalPrice;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog