Perfect choice 👍
This is exactly how real machine-coding rounds work.
Below is Day 8 – Extension Round, designed to be applied after the candidate completes Day 8 base implementation.
This teaches:
Code reading under pressure Rule addition without breaking existing logic 🟢 Day 8 — Extension Round (Mid-Interview Change)
This simulates the interviewer saying:
“Okay, now add one more requirement.”
⏱ Extension Rules (Tell Candidate)
⏰ Time for extension: 25–30 minutes ❌ Do NOT rewrite existing logic ❌ Do NOT break existing tests ❌ Do NOT change existing method signatures ✅ You may add new methods only if explicitly allowed ✅ All old behavior must still work 🧩 Extension Requirement — Partial Payment Support
New Business Requirement
The system should now support partial payments.
🔄 What Changes Conceptually?
Before:
Order could be paid only once Payment amount had to match total exactly Now:
Order can receive multiple payments Order becomes PAID only when full amount is collected Overpayment is not allowed 🧱 Updated Order States
Order can now be:
🚫 Updated Rules (Read Carefully)
Items
Can be added only in CREATED state Payments
New Rules
Payment amount must be > 0 Total paid amount must never exceed order total Multiple payments allowed until fully paid State Transitions
Cancel Rules (Updated)
Order can be cancelled only if NOT PAID Cancel clears any partial payment Cancelled order cannot be paid 🧱 Allowed Code Changes (VERY IMPORTANT)
You MAY:
Add private variables (e.g. self.paid_amount) Add helper methods (private only) You may NOT:
Remove existing validations Modify OrderItem or Payment classes 🔁 Existing Method — Updated Behavior
make_payment(payment)
Now should:
Return True if:
Order status is CREATED or PARTIALLY_PAID Total paid + payment.amount ≤ total amount Then:
Add payment amount to paid total If paid < total → PARTIALLY_PAID Else return False.
🧠 What Candidate Must Figure Out
Without being told explicitly, candidate must:
Preserve all Day 8 behavior This is where strong candidates stand out.
🧪 Extension Test File (Run After Base Tests)
📄 test_day8_extension.py
from solution import Order, OrderItem, Payment
def test_partial_payment_flow():
print("Running partial payment tests...")
order = Order("O_EXT_1")