SA-01: Code Challenge - Coffee Shop (Object Relationships) [COMPULSORY]
- Due May 20 by 11:59pm
- Points 15
- Submitting a website url
- Available after May 15 at 10am
**Project Overview
For this assignment, we'll be working with a Coffee shop-style domain. We have three models: Coffee, Customer, and Order. For our purposes, a Coffee has many Orders, a Customer has many Orders, and an Order belongs to a Customer and to a Coffee. Coffee - Customer is a many-to-many relationship. Note: You should draw your domain on paper or on a whiteboard before you start coding. Remember to identify a single source of truth for your data.
Project Setup & Folder Structure
**
- Create a new repository
- Name it (for example)
coffee-shop-challenge. - Initialize with a
README.md.
- Name it (for example)
- Clone locally
- Initialize your Python environment
- Define your folder & file layout
- Initial commit
☕ Coffee-Shop Challenge: Requirements
1. Models & Initializers
Customer
__init__(self, name)- Store a
name(must be astr, 1–15 characters).
- Store a
- Property
name- Getter returns the customer’s name.
- Setter enforces
strtype and 1–15 character length.
Coffee
__init__(self, name)- Store a
name(must be astr, at least 3 characters).
- Store a
- Property
name- Getter returns the coffee’s name.
- Immutable once initialized.
Order
__init__(self, customer, coffee, price)- Accepts a
Customerinstance, aCoffeeinstance, and aprice(float, 1.0–10.0).
- Accepts a
- Property
price- Getter returns the order price.
- Immutable once initialized; enforces type and range.
2. Object Relationships
Order.customer→ returns theCustomerinstance (type-checked)Order.coffee→ returns theCoffeeinstance (type-checked)Customer.orders()→ allOrderinstances for that customerCustomer.coffees()→ unique list ofCoffeeinstances they’ve orderedCoffee.orders()→ allOrderinstances for that coffeeCoffee.customers()→ unique list ofCustomerinstances who’ve ordered it
3. Aggregates & Associations
Customer.create_order(coffee, price)
Instantiate a newOrder, link it to this customer and the givencoffee.Coffee.num_orders()
Total count of orders for this coffee (0 if none).Coffee.average_price()
Mean of all order prices for this coffee (0 if none).
4. Bonus (Optional)
Customer.most_aficionado(coffee)(classmethod)
Return theCustomerWho’s spent the most on the givencoffee(orNoneIf no orders)
Happy Coding
Keep in mind that 165 students have already been assessed using this rubric. Changing it will affect their evaluations.
SA: Mock Code Challenge - Coffee Shop (Object Relationships) Rubric
| Criteria | Ratings | Pts |
|---|---|---|
| Customer initializer & name property Edit criterion description | 2 pts Points Initializer and name getter/setter both enforce type and length correctly (1–15 chars) and setter works 1 pts Partial Partial enforcement: either type or length checks are missing, or the setter/getter is only partly functional 0 pts No Marks No implementation or completely incorrect | pts 2 pts -- |
| Coffee initializer & name property Edit criterion description | 2 pts Full Marks Initializer and name getter enforce type and ≥3-char length correctly, and name is immutable after init 1 pts Partial Partial enforcement: type or length check missing, or immutability not enforced 0 pts No Marks No implementation or completely incorrect | pts 2 pts -- |
| Order initializer & price property Edit criterion description | 2 pts Full Marks Initializer takes Customer, Coffee, float price (1.0–10.0) and price is immutable 1 pts Partial Partial enforcement: wrong type/range checks or immutability not enforced 0 pts No Marks No implementation or completely incorrect | pts 2 pts -- |
| Relationship methods & properties Edit criterion description | 4 pts Full Marks All `Order.customer`, `Order.coffee`, `Coffee.orders()`, `Coffee.customers()`, `Customer.orders()`, `Customer.coffees()` work correctly and return proper unique lists 3 pts Partial One method has minor bug (e.g. duplicates or wrong type), but the rest work 2 pts Partial Some methods work correctly, others missing or majorly flawed 1 pts Partial Only one or two relationship methods implemented correctly 0 pts Partial No relationship methods are implemented | pts 4 pts -- |
| Aggregate/association methods Edit criterion description | 3 pts Full Marks Customer.create_order()`, `Coffee.num_orders()`, and `Coffee.average_price()` are all correct 2 pts Partial One of the three methods is missing or has a bug 1 pts Partial Aggregate methods exist but are mostly incorrect 0 pts No Marks No aggregate/association methods implemented | pts 3 pts -- |
| Bonus: Customer.most_aficionado(coffee) Edit criterion description | 2 pts Full Marks Correctly returns the customer who spent the most or `None` if no orders 1 pts Partial Method exists but fails on edge cases (e.g. ties or empty orders) 0 pts No Marks Not implemented or completely incorrect | pts 2 pts -- |