Welcome to the Coffee Shop Challenge, a Python object-oriented programming (OOP) project designed to model a simple coffee shop system with customers, coffees, and orders.
This project emphasizes core OOP principles such as encapsulation, relationships (one-to-many, many-to-many), class vs instance methods, and data validation.
In this system, we model three core entities:
- Coffee
- Customer
- Order
- A Customer has many Orders
- A Coffee has many Orders
- An Order belongs to both a Customer and a Coffee
- Therefore, Customers and Coffees have a many-to-many relationship through Orders
coffee-shop-challenge/
├── Pipfile
├── Pipfile.lock
├── debug.py
├── customer.py
├── coffee.py
├── order.py
└── tests/
├── customer_test.py
├── coffee_test.py
└── order_test.py
git clone git@github.com:<your-username>/coffee-shop-challenge.git
cd coffee-shop-challengepipenv install
pipenv shellUse debug.py to manually run and test your objects and relationships.
python debug.pyTo run all unit tests:
python -m unittest discover tests-
__init__(self, name)– must be a string between 1 and 15 characters -
.nameproperty with validation -
.orders()– list of this customer's orders -
.coffees()– unique list of coffees this customer has ordered -
.create_order(coffee, price)– creates a new order for a coffee
-
__init__(self, name)– name must be a string with at least 3 characters -
.nameproperty (read-only after creation) -
.orders()– list of orders for this coffee -
.customers()– unique list of customers who’ve ordered this coffee -
.num_orders()– total number of orders for this coffee -
.average_price()– average order price for this coffee
-
__init__(self, customer, coffee, price)– accepts aCustomer,Coffee, andprice(float between 1.0 and 10.0) -
.customerand.coffeeproperties (read-only) -
.priceproperty (read-only with validation)
-
Customer.most_aficionado(coffee)– class method that returns the customer who spent the most on a given coffee
- Object-Oriented Design (OOP)
- Class and instance attributes/methods
- Data validation and encapsulation
- Relationships (1-to-many, many-to-many)
- Aggregation and basic analytics
George GitHub
This project is for educational purposes only and is licensed under the MIT License.