From 5d817e7591e18691460e28a4682aac7ab69a8563 Mon Sep 17 00:00:00 2001 From: Bohdana Salabai Date: Sat, 21 Dec 2024 13:35:50 +0100 Subject: [PATCH] 'Solution' --- app/main.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index b2d096bda..e037fcef1 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,40 @@ class Car: - # write your code here - pass + + def __init__(self, comfort_class: int, clean_mark: int, + brand: str) -> None: + self.comfort_class = comfort_class + self.clean_mark = clean_mark + self.brand = brand class CarWashStation: - # write your code here - pass + + def __init__(self, distance_from_city_center: float, clean_power: float, + average_rating: float, count_of_ratings: int) -> None: + self.distance_from_city_center = distance_from_city_center + self.clean_power = clean_power + self.average_rating = average_rating + self.count_of_ratings = count_of_ratings + + def serve_cars(self, cars: list) -> float: + washing_price = 0 + for car in cars: + if self.clean_power > car.clean_mark: + washing_price += self.calculate_washing_price(car) + self.wash_single_car(car) + return washing_price + + def calculate_washing_price(self, car: Car) -> float: + return round((car.comfort_class + * (self.clean_power - car.clean_mark) + * self.average_rating + / self.distance_from_city_center), 1) + + def wash_single_car(self, car: Car) -> None: + car.clean_mark = self.clean_power + + def rate_service(self, rate: int) -> None: + self.average_rating = round((self.average_rating + * self.count_of_ratings + rate) + / (self.count_of_ratings + 1), 1) + self.count_of_ratings += 1