Object-Oriented Delivery Cost Dashboard Service
Goal
Design and implement an object-oriented service to track delivery costs across multiple drivers, support live dashboard totals, and track payment status.
API Requirements
Implement a class (or set of classes) that supports:
-
add_driver(driver_id: integer, usd_hourly_rate: float)
-
Add a driver who is not yet in the system.
-
record_delivery(driver_id: integer, start_time, end_time)
-
Record a completed delivery for an existing driver.
-
Deliveries are entered immediately after completion.
-
No delivery exceeds 3 hours.
-
Time precision must be at least one second.
-
Drivers have individual hourly rates and can run multiple overlapping deliveries; each delivery is paid independently as duration_in_hours × driver_rate.
-
Example: $10.00/hr × 1h30m = $15.00.
-
get_total_cost()
-
Return the aggregated cost of all recorded deliveries across all drivers (suitable for a live dashboard; exact formatting not required).
-
pay_up_to(pay_time: integer, Unix time seconds from epoch)
-
Mark as paid all deliveries that ended at or before pay_time.
-
get_total_cost_unpaid()
-
Return the total cost of all recorded deliveries that have not yet been paid.
Constraints and Assumptions
-
Inputs are valid; concurrency and thread-safety are out of scope.
-
You may discuss and justify time representation (e.g., Unix seconds, ISO-8601 strings, timezone handling) and any assumptions.
-
Demonstrate good OOP practices and share what you would do differently in production.