0% found this document useful (0 votes)
35 views3 pages

Online (B1+B2)

Uploaded by

alaminbuetcse22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Online (B1+B2)

Uploaded by

alaminbuetcse22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

January 2023 CSE 108

Online 1
Time: 30 minutes
Subsections B1 & B2

You need to simulate an Online Shopping Management System using basic OOP concepts. The system
should allow the manager to add different products to the online store, and the users can select and add
products to their carts from the store. For simplicity, the functionalities from both ends would be incorporated
in a single program.

Tasks
1. Create a class named Product with private member variables for the product’s name and price. For
storing strings, you can use the C++ <string> library if convenient.
2. Include public member functions to:

• Set the product details (product name, price).


• Get the product details.
• Display the product details.
3. Implement the appropriate constructor(s) and destructor for the Product class.

4. Create a class named OnlineStore that manages the collection of products to be added to the store.
5. Include private member variables to store the products [use arrays with a maximum specified size (for
example: 100)].
6. Include public member functions to:

• Add a new product to the store.


• Display all the available products in the store.
7. Implement the appropriate constructor(s) and destructor for the OnlineStore class.

8. Create a class named ShoppingCart that manages the collection of products to be added to the cart.
9. Include private member variables to store the products [use arrays with a maximum specified size].
10. Include public member functions to:
• Add a new product to the cart.
• Display the products present in the cart.
• Show the total cost of the cart.
Including the following would be regarded as Bonus (+20%):
• Remove an added product from the cart.

11. Implement the appropriate constructor(s) and destructor for the ShoppingCart class.

See the expected outputs below to have a clear understanding.

1
Sample main()
int main() {
OnlineStore store;

// Add products to the online store


Product product1("Laptop", 999.99);
Product product2("Smartphone", 699.99);
Product product3("Headphones", 99.99);

store.addProduct(product1);
store.addProduct(product2);
store.addProduct(product3);

// Display available products


store.displayProducts();

// Create a new shopping cart


ShoppingCart cart;

// Add products to the shopping cart


cart.addProduct(product1);
cart.addProduct(product2);

// Display the shopping cart


cart.displayCart();

// Add another product to the cart


cart.addProduct(product3);

// Display the updated shopping cart


cart.displayCart();

// Remove a product from the cart


cart.removeProduct("Laptop");

// Display the updated shopping cart


cart.displayCart();

return 0;
}

2
Expected Output
Available Products in the Store:
Product: Laptop - Price: $999.99
Product: Smartphone - Price: $699.99
Product: Headphones - Price: $99.99

Shopping Cart:
Product: Laptop - Price: $999.99
Product: Smartphone - Price: $699.99
Total Cost: $1699.98

Shopping Cart:
Product: Laptop - Price: $999.99
Product: Smartphone - Price: $699.99
Product: Headphones - Price: $99.99
Total Cost: $1799.97

Shopping Cart:
Product: Smartphone - Price: $699.99
Product: Headphones - Price: $99.99
Total Cost: $799.98

You might also like