← 返回 rippling 的题目列表Design an API for a food delivery system
类型:online_judge
Design an API similar to a food delivery system, including tracking driver info, recording delivery statuses, and calculating the cost. Define the functions of the API in detail, including:
track_driver_info(driver_id): Track driver information, update location, etc.
record_delivery(order_id, delivery_status): Record the status of the delivery and update the order.
calculate_cost(order_id): Calculate the delivery cost based on recorded information.
Specify the required data structures, detailed implementation of the APIs, and edge cases. Consider order status updates and driver status refresh frequency.
Here are a few examples:
Input: track_driver_info('driver123')
Input: record_delivery('order456', 'delivered')
Input: calculate_cost('order456')
Provide an implementation for these API functions.
Example
Input
track_driver_info('driver123')