Food-Delivery Driver Payments System
Context
You are designing a small, object-oriented component to track and pay food-delivery drivers based on their hourly rate and completed delivery durations. Deliveries are recorded only after completion and never exceed 3 hours.
Assume all times are UTC and recorded with at least 1-second precision using Unix epoch time.
Requirements
Implement an object-oriented API with the following methods:
-
add_driver(driver_id, usd_hourly_rate)
-
Registers a driver and their current hourly rate in USD.
-
record_delivery(driver_id, start_time, end_time)
-
Records a completed delivery for the driver.
-
Time format must support ≥1-second precision.
-
Each delivery duration ≤ 3 hours.
-
Deliveries are recorded only after completion (end_time ≤ now).
-
get_total_cost()
-
Returns the total cost of all deliveries (paid and unpaid).
Then extend the system with:
-
pay_up_to(pay_time)
-
Marks deliveries as paid if their end_time ≤ pay_time (Unix epoch time).
-
get_total_cost_unpaid()
-
Returns the total cost of all unpaid deliveries.
Discussion Prompts
-
Storage choices (in-memory vs. persistent), data modeling, and indexing.
-
Assumptions (time zone, precision, rate changes, rounding).
-
OOP practices (entities, services, repositories, immutability, interfaces).
-
Any sensible deviations from production for an interview-quality solution.