Here is the question with detailed explanation:
In python, write code to show the typical interactions between objects that represent the
foundations of an e-commerce engine (Online shopping cart).
There will be classes for users, products, carts and orders.
It will work this way -
User will have one Cart in which he/she can add many Products. So a cart will have many
Products. To make a purchase, User will
"checkout" the Cart and an Order will be created.
Finally write a "main" or "runner" script that can be run in the terminal as follows -
1. First, it will prompt the user for name,email and create a user object.
2. Show a list of products (id, name, model, price)
(for products no need to use a database, you can directly hard code a few product objects in the
script to keep it simple)
3. prompt user to enter 2 products along with quantities which will be added to the Cart.
4. Calculate total price and show the amount on screen. Ask the user to enter the correct
amount again. If he enters it correctly,
consider payment is complete! and create an Order
5. print the order details (invoice) on screen and exit
ecengine.py - Ecommerce engine source
testfile.py - unit test code
1) I have used unittest.py for testing ... elaborate test
cases have not been written.
2) I have checked out PEP8 for coding conventions.