-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (22 loc) · 1.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from traffic_system.traffic_data import log_car_speed, get_daily_average_speed, get_cars_exceeding_threshold, get_all_car_speeds
def main():
# initialize_database()
# Calculate the daily average speed
average_speed = get_daily_average_speed()
print(f"Today's average speed: {average_speed} km/h")
# Find cars exceeding the threshold
violators = get_cars_exceeding_threshold()
if violators:
print("Cars exceeding speed limit and subject to fines:")
for car_id, license_plate, speed in violators:
print(f"Car ID: {car_id}, License Plate: {license_plate}, Speed: {speed} km/h")
else:
print("No violations today.")
# Retrieve and display all data in the cars table
print("\nAll recorded car speeds:")
all_data = get_all_car_speeds()
for record in all_data:
car_id, license_plate, speed, recorded_date = record
print(f"Car ID: {car_id}, License Plate: {license_plate}, Speed: {speed} km/h, Date: {recorded_date}")
if __name__ == "__main__":
main()