-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriver.py
More file actions
22 lines (19 loc) · 728 Bytes
/
Copy pathDriver.py
File metadata and controls
22 lines (19 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Driver:
# Sets up a Driver instance with a unique ID
def __init__(self, driver_id):
self.driver_id = driver_id
self.truck = None
# Attempts to assign an available truck to the driver; returns True if successful
def assign_truck(self, truck_list):
# Look for a truck that is not currently assigned to a driver
for truck in truck_list:
if truck.driver is None:
truck.driver = self
self.truck = truck
return True
return False
# Unassigns the current truck from the driver
def remove_truck(self):
if self.truck is not None:
self.truck.driver = None
self.truck = None