Open YakutovDmitriy opened 5 years ago
I did not notice that format of files is YAML and wrote the program on JSON, I thought it was just an example. And when I realized that these were files for writing, it was too late to correct, sorry, I hope it is not that severe.
If your implementation works, format of file doesn't matter :)
Your program is very good. Json is very good solution for storing this kind of data. Actually I wanted to make json examples but I thought that I is too difficult for exam to discover new library.
Also it is pretty cool that you used argparse to work with arguments. You get full score for exam
Actually you didn't satisfied one of main requirements: your program fails with empty set of argument, but it doesn't spoit the impression :)
wow, thank you. Apparently I've spent more time on writing, than testing(
I want to share a link with your program with other student to show how it could be if you don't mind. Is it ok?
Yes, sure
Main requirements
Your program should never fail.
You are free to implement the task as you want. In particular, if there are some uncertainties, you have to decide what to do.
You are free to add some functionality. Please describe all features you added.
Implement application
taxi.py
to work with taxi service.Your taxi service is working in 1D-world (on straight line). Every place is defined by its coordinate (one number). Distance between two points is a difference between their coordinates (in km).
You have list of your drivers, it is stored in file drivers.tx. Every driver has several properties:
0
if he is free)Also you have list of all orders you ever had. They are stored in file orders.tx. Every order has several properties:
1, 2, 3, ...
)Add new driver:
python taxi.py add-driver <Name> <Position> <Car> <Speed>
Command should add new free driver with given parameters
Add new order:
python taxi.py order <From position> <To position>
Command should add new order. If there is no free driver, you should decline this order and print a message about it. Otherwise you should find free driver who will come earlier then any other (use speed of a car to calculate this time) and print a message like
Driver Evgeniy will come in 0.1 hours (order-id: 5)
. Do not forget to change state of chosen driverFinish order:
python taxi.py finish <Order-id>
Command should finish order with id
<Order-id>
. If order does not exist or order's status is notIn progress
, print a message about it. Otherwise finish this order and change location and status of driver and print the cost of this order. Cost is calculated in the following way:300 * <hours> + 5 * <distance>
where<hours>
is travel time in hours and<distance>
is distance between source and destination in km.