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:
1- Customer can add any item to the cart in desired quantity.
Remember if customer added the same item in the cart again, your implementation will not add
this as a new item it will check if the item already exists than it will just add the new quantity in
the previous and update other data.
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;
};
Comments
Leave a comment