From 3dd19d792532fda6e6dc4a5fa9195f37a525d82c Mon Sep 17 00:00:00 2001 From: Beliar24 Date: Sun, 3 Nov 2024 18:26:40 +0200 Subject: [PATCH 1/3] wash car implemented --- app/main.py | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index b2d096bd..64fb64af 100644 --- a/app/main.py +++ b/app/main.py @@ -1,8 +1,39 @@ 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: int, + 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 serve_cars(self, cars: list) -> float: + total_income = 0.0 + for car in cars: + if car.clean_mark < self.clean_power: + income = self.calculate_washing_price(car) + total_income += income + self.wash_single_car(car) + return round(total_income, 1) + + def calculate_washing_price(self, car: Car) -> float: + return (car.comfort_class * (self.clean_power - car.clean_mark) * self.average_rating / + self.distance_from_city_center) + + def wash_single_car(self, car: Car) -> None: + if self.clean_power > car.clean_mark: + car.clean_mark = self.clean_power + + def rate_service(self, new_rating: int) -> None: + total_ratings = self.count_of_ratings + 1 + self.average_rating = round(((self.average_rating * self.count_of_ratings) + new_rating) / total_ratings, 1) + self.count_of_ratings = total_ratings From 65fd014f7a8103b6a9d520e9f3a62e2a53216d67 Mon Sep 17 00:00:00 2001 From: Beliar24 Date: Sun, 3 Nov 2024 18:28:54 +0200 Subject: [PATCH 2/3] wash car implemented --- app/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 64fb64af..0cb52b4b 100644 --- a/app/main.py +++ b/app/main.py @@ -26,7 +26,8 @@ def serve_cars(self, cars: list) -> float: return round(total_income, 1) def calculate_washing_price(self, car: Car) -> float: - return (car.comfort_class * (self.clean_power - car.clean_mark) * self.average_rating / + return (car.comfort_class * (self.clean_power - car.clean_mark) * + self.average_rating / self.distance_from_city_center) def wash_single_car(self, car: Car) -> None: @@ -35,5 +36,7 @@ def wash_single_car(self, car: Car) -> None: def rate_service(self, new_rating: int) -> None: total_ratings = self.count_of_ratings + 1 - self.average_rating = round(((self.average_rating * self.count_of_ratings) + new_rating) / total_ratings, 1) + self.average_rating = round( + ((self.average_rating * self.count_of_ratings) + new_rating) / + total_ratings, 1) self.count_of_ratings = total_ratings From e57f5da553b691464d3ff74f635ca68092fa88c4 Mon Sep 17 00:00:00 2001 From: Beliar24 Date: Sun, 3 Nov 2024 18:30:37 +0200 Subject: [PATCH 3/3] wash car implemented --- app/main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 0cb52b4b..3cf85769 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,8 @@ class Car: - def __init__(self, comfort_class: int, clean_mark: int, brand: str) -> None: + 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 @@ -26,9 +29,8 @@ def serve_cars(self, cars: list) -> float: return round(total_income, 1) def calculate_washing_price(self, car: Car) -> float: - return (car.comfort_class * (self.clean_power - car.clean_mark) * - self.average_rating / - self.distance_from_city_center) + return (car.comfort_class * (self.clean_power - car.clean_mark) + * self.average_rating / self.distance_from_city_center) def wash_single_car(self, car: Car) -> None: if self.clean_power > car.clean_mark: @@ -37,6 +39,6 @@ def wash_single_car(self, car: Car) -> None: def rate_service(self, new_rating: int) -> None: total_ratings = self.count_of_ratings + 1 self.average_rating = round( - ((self.average_rating * self.count_of_ratings) + new_rating) / - total_ratings, 1) + ((self.average_rating * self.count_of_ratings) + new_rating) + / total_ratings, 1) self.count_of_ratings = total_ratings