0% found this document useful (0 votes)
53 views

CSE111 Assignment-1

1. The document describes an assignment to create an online store system using Python classes. This includes classes for products, online store items, customers, orders, and an online store. 2. The product and online store item classes are to be created along with methods to calculate prices and shipping costs. 3. A customer class is also to be made with attributes for customer details. 4. An order class needs methods to calculate totals and remove products, and associate customers and products. 5. Finally, an online store class must have methods to manage products, customers, and placing orders. The classes are to be tested by creating instances and printing them.

Uploaded by

Jubair Sami
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)
53 views

CSE111 Assignment-1

1. The document describes an assignment to create an online store system using Python classes. This includes classes for products, online store items, customers, orders, and an online store. 2. The product and online store item classes are to be created along with methods to calculate prices and shipping costs. 3. A customer class is also to be made with attributes for customer details. 4. An order class needs methods to calculate totals and remove products, and associate customers and products. 5. Finally, an online store class must have methods to manage products, customers, and placing orders. The classes are to be tested by creating instances and printing them.

Uploaded by

Jubair Sami
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

Assignment : Online Store

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]

2. Create a subclass called `OnlineStoreItem` that inherits from `Product`. The


`OnlineStoreItem` class should add an attribute for `shipping_weight` and create the
`calculate_shipping_cost` method to return the cost of shipping based on the
`shipping_weight` attribute. [shipping_cost = 2.5 * shipping_weight].

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.

2. Create the `OnlineStoreItem` class and test it by creating a few instances of


`OnlineStoreItem` and printing them out using the `__str__` method. Verify that the
`calculate_shipping_cost` method works as expected.
3. Create the `Customer` class and test it by creating a few instances of `Customer` 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)

# View all products in the store


print("1=====================")
print(store)
print("2=====================")
# Create a new customer
customer1 = Customer("Alice",
"[email protected]", "123 Main St.","555-1234")

# Register the customer with the store


store.register_customer(customer1)

store.customers_info()
print("3=====================")
# Place an order for the customer
order1 = store.place_order(customer1, [product1,
product2], [50, 25])

# View the order


print(order1)
print("4=====================")
# Remove a product from the order
order1.remove_product(product1)

# View the updated order


print(order1)
print("4=====================")

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.

Submission Form : https://forms.gle/MKeqfgeJPfwpHrEp7

You might also like