toll_collect/app.py

28 lines
855 B
Python

import json
from vehicle_group import get_vehicle_group
class App:
def __init__(self):
self._co2_class = None
self._read_configs()
def _read_configs(self):
with open("config/co2_classe.json") as json_file:
self._co2_class = json.load(json_file)
def get_co2_class(self, registrations_date, emission, vehicle_type, axis_type, power, cabin):
vehicle_grp = get_vehicle_group(power, cabin, vehicle_type, axis_type)
co2_limit = self._co2_class[vehicle_grp][registrations_date]
print(vehicle_grp)
print(co2_limit)
if emission < (co2_limit * 0.5):
print("Klasse 4")
elif emission < (co2_limit * 0.92):
print("Klasse 3")
elif emission < (co2_limit * 0.95):
print("Klasse 2")
else:
print("Klasse 1")