This Python-based store management system offers functionality to manage products in a store, handle customer orders, and apply promotions, all through an interactive user interface.
ProductClass:- Attributes:
name,price,quantity,active, andpromotions. - Supports actions such as:
- Activating or deactivating a product based on availability.
- Modifying product details (e.g., price, quantity).
- Displaying product information.
- Includes multiple product types:
NonStockedProduct: Products without physical stock, such as digital licenses.LimitedProduct: Products with a maximum purchase limit per order.
- Attributes:
- Define and apply promotional discounts, including:
PercentDiscount: Applies a percentage-based discount.SecondHalfPrice: Every second product is half-price.ThirdOneFree: Buy 3, pay for 2.
- Products can have multiple promotions applied, calculated cumulatively.
StoreClass:- Manage a collection of products with features like:
- Adding and removing products.
- Viewing all active products.
- Calculating total quantity in stock.
- Processing customer orders.
- Manage a collection of products with features like:
- Menu options:
- List all products in the store.
- Show the total quantity of items in the store.
- Place an order by selecting products and quantities.
- Quit the application.
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Ensure Python 3.x is installed.
-
Install any DEV dependencies if required:
pip install -r dev-requirements.txt
- Navigate to the project directory.
- Execute the main script:
python main.py
- Displays all active products in the store with their details, including applied promotions.
- Summarizes the total quantity of items available in the store.
- Users can select products by their ID and specify the desired quantity.
- The system checks availability and applies relevant promotions.
- Total price is calculated, and inventory is updated after purchase.
Upon startup, the application initializes with the following products:
| Product Name | Price | Quantity | Notes |
|---|---|---|---|
| MacBook Air M2 | $1450 | 100 | |
| Bose QuietComfort Earbuds | $250 | 500 | |
| Google Pixel 7 | $500 | 250 | |
| Windows License | $125 | 0 | Non-stocked product |
| Shipping | $10 | 250 | Limited to 1 per order |
-
products.py:- Defines product-related functionality and promotion logic.
-
store.py:- Handles store operations, including inventory management and order processing.
-
main.py:- Provides the user interface and serves as the entry point for the application.
- Run tests using
pytest:pytest test_products.py
- Ensure product management operations (add, remove, modify) work correctly.
- Validate correct application of multiple promotions on purchases.
- Test quantity limits on
LimitedProductand out-of-stock handling.
- MacBook Air M2:
- Second Half Price
- 30% Off
- User selects MacBook Air M2 and orders 3 units.
- The following calculations are performed:
- Base price: (1450 \times 3 = 4350)
- Second Half Price discount: (1450 / 2 = 725)
- 30% Off discount: (4350 \times 0.3 = 1305)
- Final price: (4350 - 725 - 1305 = 2320)
- Total cost displayed:
$2320. - Inventory updated to 97 units.