CSE111 Assignment-1
CSE111 Assignment-1
Course: CSE111
Marks : 20
Submission Deadline: 01 - 04- 23 (11:59 PM)
You have been tasked with creating an online store system using object-oriented programming in Python.
The system should consist of classes for products, online store item, customers, orders, and the online
store itself.
Requirements:
1. Create a Product class with attributes for `name`, `quantity` and `price`. Implement two
methods called calculate_price that returns the calculated price by considering quantity and price
variables and `__str__` that returns a string representation of the product.
[calculated_price = price * quantity]
3. Create a `Customer` class with attributes for `name`, `email`, `address`, and
`phone_number`. Implement a method called `__str__` that returns a string representation of the
customer.
4. Create an `Order` class with attributes for `customer`, `products`, and `quantities`.
Implement methods to calculate the order total and remove a product from the order. Implement a method
called `__str__` that returns a string representation of the order.
5. Create a `OnlineStore` class that has attributes for `name` and `products`. Implement methods
to add and remove products, register customers, and place an order. Implement a method called
`__str__` that returns a string representation of the store, including all of its products.
Tasks:
1. Create the `Product` class and test it by creating a few instances of `Product` and printing them out
using the `__str__` method.
4. Create the `Order` class and test it by creating a few instances of `Order` and printing them out
using the `__str__` method. Verify that the `calculate_total` and `remove_product`
methods work as expected.
5. Create the `OnlineStore` class and test it by creating a few instances of `OnlineStore` and
printing them out using the `__str__` method. Verify that the `add_product`,
`remove_product`, `register_customer`, and `place_order` methods work as expected.
Output:
# Driver code 1=====================
Products:
# Create some products
Apple ($0.50) x 100
product1 = OnlineStoreItem("Apple", 0.5, 0, 0.2) Banana ($0.30) x 50
Orange ($0.40) x 75
product2 = Product("Banana", 0.3, 0) 2=====================
product3 = OnlineStoreItem("Orange", 0.4, 0, Total Customer : 1
Name : Alice
0.3) Email : [email protected]
Address : 123 Main St.
Phone : 555-1234
# Create an online store 3=====================
Order for Alice:
store = OnlineStore() Apple ($0.50) x 100 x 50
Banana ($0.30) x 50 x 25
Total: $65.00
# Add the products to the store 4=====================
Order for Alice:
store.add_product(product1, 100) Banana ($0.30) x 50 x 25
store.add_product(product2, 50) Total: $15.00
4=====================
store.add_product(product3, 75)
store.customers_info()
print("3=====================")
# Place an order for the customer
order1 = store.place_order(customer1, [product1,
product2], [50, 25])
Submission:
Submit a Python file that contains all of the classes and methods required for this assignment, as well as
code that creates instances of each class and tests their functionality. Include comments in your code to
explain what each class and method does.