# Traffic system components class Vehicle: """Represents vehicles in traffic simulations""" def __init__(self, destination, borntime): pass class Lane: "Represents a lane with (possible) vehicles" def __init__(self, length): pass def __str__(self): return "A lane" def enter(self, vehicle): pass def is_last_free(self): pass def step(self): pass def get_first(self): pass def remove_first(self): pass def number_in_lane(self): pass def demo_lane(): """For demonstration of the class Lane""" a_lane = Lane(10) print(a_lane) v = Vehicle('N', 34) a_lane.enter(v) print(a_lane) a_lane.step() print(a_lane) for i in range(20): if i % 2 == 0: u = Vehicle('S', i) a_lane.enter(u) a_lane.step() print(a_lane) if i % 3 == 0: print(' out: ', a_lane.remove_first()) print('Number in lane:', a_lane.number_in_lane()) class Light: """Represents a traffic light""" def __init__(self, period, green_period): pass def __str__(self): return "a Light" def __repr__(self): pass def step(self): pass def is_green(self): pass def demo_light(): """Demonstrats the Light class""" a_light = Light(7, 3) for i in range(15): print(i, a_light, a_light.is_green()) a_light.step() def main(): """Demonstrates the classes""" print('\nLight demonstration\n') demo_light() print('\nLane demonstration') demo_lane() if __name__ == '__main__': main()