Design an object-oriented scheduler for a single autonomous vehicle.
The vehicle starts at a known location at time 0. Ride requests arrive in input order, and the vehicle must serve accepted requests in that same order. Each request contains:
-
request_id
-
request_time
-
pickup_location
-
dropoff_location
Assume a helper function travel_time(a, b) returns the travel time between two locations.
Requirements:
-
Add a new ride request.
-
Simulate execution of the schedule and return the final completion time.
-
Support a
skip_to_next_event()
operation so the simulation can jump directly to the next arrival, pickup, or drop-off event instead of advancing one time unit at a time.
-
Support
cancel(request_id)
for any request whose pickup has not started yet.
-
Explain the core classes, state transitions, APIs, and how you would test edge cases.
Discuss a clean design first; code is optional.