From a7fdf62f8100b1fb400973cd608b1e635683081f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=9D=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=BB=D0=BE=D0=BA=D0=BE=D0=B2?= Date: Sat, 4 Jan 2025 11:23:43 +0200 Subject: [PATCH] Solution --- app/main.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index b2d096bda..f6b403bed 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,38 @@ class Car: - # write your code here - pass + def __init__(self, comfort_class, clean_mark, brand): + 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, clean_power, average_rating, count_of_ratings): + 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 calculate_washing_price(self, car): + 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): + if car.clean_mark < self.clean_power: + car.clean_mark = self.clean_power + + def serve_cars(self, cars): + total_income = 0 + for car in cars: + if car.clean_mark < self.clean_power: + total_income += self.calculate_washing_price(car) + self.wash_single_car(car) + return round(total_income, 1) + + def rate_service(self, rate): + self.average_rating = round( + (self.average_rating * self.count_of_ratings + rate) / (self.count_of_ratings + 1), + 1, + ) + self.count_of_ratings += 1 \ No newline at end of file