Skip to content
Zeni Study
  • Pages
    • Learn Python In 7 Days
      • Day 1 : Variable + if/else
      • Day 2: Loops
      • Day 3 : Array + String
      • Day 4 — Functions
      • Day 5 — Dictionaries - Hashmap
      • Day 6 — Files & Errors
      • Day 7 — Mini Project & Programmer Thinking
    • Machine Coding:
      • Day 1 — Bank account + Wallet :
      • Day 2 : RateLimiter + seat booking
      • Day 3 : Library Management + Classroom Attendance System
      • Day 4 : Bank account and notification system.
      • Day 5 : Key-value and payment processor.
      • Day 6 : Discount engine + Seat booking( in depth)
      • Day 7: Parking lot System :
    • Machine coding extended:
      • Day 7.5 — Parking Lot (Constraint-Heavy Variant)
      • Day 8 : Order + Payment System
      • icon picker
        Day 8 — Extension Round (Mid-Interview Change)
      • Day 9 — Ticket Booking with Expiry (Simulated Time)
      • Day 9 — Extension Round (Seat Lock Ownership + Forced Unlock)
    • SQL + DB Thinking course
      • Day 1 — Tables, Rows & Thinking in Data
      • Day 2 — Relationships & Foreign Keys (Thinking in Connections)
      • Day 3 — Filtering, Aggregation & Answering Data Questions
      • Day 4 — JOINs (Combining Tables the Right Way)
      • Day 5 — Subqueries, EXISTS & NOT EXISTS (Thinking in Layers)
      • Day 6 — Indexes, Constraints & How Databases Think
      • Day 7 — Full SQL Interview Simulation (SDE-1 Ready)
      • Extended Day 1 — Core Business Systems (Deep Practice)
      • Extended Day 2 — Booking & Platform Systems (High-Depth Practice)
      • Extended Day 3 — Content & Learning Platforms (Capstone Practice)
    • LLD: Java
      • DAY 1 — Core Foundations (SDE-2 Level)
      • DAY 2 — State, Time & Domain Correctness
      • DAY 3 — Extensibility & Failure Handling (SDE-2 Core Signal)
      • DAY 4 — Concurrency, Scheduling & Consistency (SDE-2 Critical)
      • DAY 5 — Workflow Design & Config-Driven Systems (SDE-2+)
      • DAY 6 — Eventing & Usage-Based Systems (Advanced SDE-2)
      • DAY 7 — Interview Simulation (Hard, Production-Grade)
      • Hidden Edge Cases Interviewers Expect (Day-wise)
      • Detailed Testing file:
    • Assignment:
      • If else Practice Set

Day 8 — Extension Round (Mid-Interview Change)

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
Safe extension
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:
CREATED
PARTIALLY_PAID
PAID
CANCELLED

🚫 Updated Rules (Read Carefully)

Items

Same as before
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

Current State
Action
Result State
CREATED
partial payment
PARTIALLY_PAID
PARTIALLY_PAID
partial payment
PARTIALLY_PAID
PARTIALLY_PAID
final payment
PAID
CREATED
full payment
PAID
PAID
any payment
CANCELLED
any payment
There are no rows in this table

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)
Update internal logic
Add helper methods (private only)

You may NOT:

Change method signatures
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
Payment amount > 0
Total paid + payment.amount ≤ total amount
Payment is successful
Then:
Add payment amount to paid total
Update state:
If paid < total → PARTIALLY_PAID
If paid == total → PAID
Else return False.

🧠 What Candidate Must Figure Out

Without being told explicitly, candidate must:
Track paid_amount
Compare against total
Update state correctly
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")

order.add_item(OrderItem("I1", 100, 2)) # total = 200

assert order.get_total_amount() == 200
assert order.get_status() == "CREATED"

assert order.make_payment(Payment(50)) is True
assert order.get_status() == "PARTIALLY_PAID"

assert order.make_payment(Payment(100)) is True
assert order.get_status() == "PARTIALLY_PAID"

assert order.make_payment(Payment(50)) is True
assert order.get_status() == "PAID"

print("✅ Partial payment flow tests passed")


def test_overpayment_not_allowed():
print("Running overpayment tests...")

order = Order("O_EXT_2")
order.add_item(OrderItem("I2", 100, 1)) # total = 100

assert order.make_payment(Payment(70)) is True
assert order.make_payment(Payment(40)) is False # exceeds total

print("✅ Overpayment tests passed")


def test_cancel_after_partial_payment():
print("Running cancel after partial payment tests...")

order = Order("O_EXT_3")
order.add_item(OrderItem("I3", 100, 1))

assert order.make_payment(Payment(30)) is True
assert order.get_status() == "PARTIALLY_PAID"

assert order.cancel() is True
assert order.get_status() == "CANCELLED"

assert order.make_payment(Payment(70)) is False

print("✅ Cancel after partial payment tests passed")


def test_no_payment_after_paid():
print("Running no payment after PAID tests...")

order = Order("O_EXT_4")
order.add_item(OrderItem("I4", 50, 2)) # total = 100

assert order.make_payment(Payment(100)) is True
assert order.get_status() == "PAID"

assert order.make_payment(Payment(10)) is False

print("✅ No payment after PAID tests passed")


if __name__ == "__main__":
test_partial_payment_flow()
test_overpayment_not_allowed()
test_cancel_after_partial_payment()
test_no_payment_after_paid()

print("\n🎉 ALL DAY 8 EXTENSION TESTS PASSED SUCCESSFULLY")

✅ Pass Criteria for Extension Round

Candidate passes Day 8 Extension if:
All original Day 8 tests pass
All extension tests pass
No signature changes
No breaking of existing behavior
Correct state transitions
Clean handling of partial payments

🧠 Post-Extension Reflection (Must Answer)

Ask candidate:
What new state did you introduce and why?
How did you ensure backward compatibility?
Where did you store paid amount and why?
What was the riskiest change you made?
How would you test this further?

⭐ Extension Golden Rule

Anyone can write new code. Engineers extend code without breaking it.

🎯 What This Achieves

With Day 8 + Extension:
Candidate can handle changing requirements
Can extend real backend workflows
Is ready for strong SDE-1 / borderline SDE-2 interviews
Demonstrates real engineering maturity
If you want next, I can:
Add extension round to Day 9
Combine Days 7.5–9 into one mega mock
Create interviewer scoring rubric
Turn this into a paid assessment
Just tell me what’s next 🚀
 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.