diff --git a/app/main.py b/app/main.py index b2d096bda..0eefef0df 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,44 @@ 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: int, + 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 calculate_washing_price(self, car: Car) -> float: + if car.clean_mark >= self.clean_power: + return 0 + cost = ( + car.comfort_class + * (self.clean_power - car.clean_mark) + * self.average_rating + / self.distance_from_city_center + ) + return round(cost, 1) + + def wash_single_car(self, car: Car) -> None: + if car.clean_mark < self.clean_power: + car.clean_mark = self.clean_power + + def serve_cars(self, cars: list) -> float: + total_cost = 0 + for car in cars: + if car.clean_mark < self.clean_power: + total_cost += self.calculate_washing_price(car) + self.wash_single_car(car) + return round(total_cost, 1) + + def rate_service(self, rating: int) -> None: + total_score = self.average_rating * self.count_of_ratings + total_score += rating + self.count_of_ratings += 1 + self.average_rating = round(total_score / self.count_of_ratings, 1)