-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
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_rating: 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_rating | ||
|
||
def serve_cars(self, cars: list[Car]) -> float: | ||
income = 0.0 | ||
for car in cars: | ||
|
||
if car.clean_mark <= self.clean_power: | ||
income += self.calculate_washing_price(car) | ||
self.wash_single_car(car) | ||
|
||
return round(income, 1) | ||
|
||
def calculate_washing_price(self, car: Car) -> float: | ||
washing_price = (car.comfort_class * | ||
(self.clean_power - car.clean_mark) * | ||
self.average_rating / self.distance_from_city_center) | ||
return round(washing_price, 1) | ||
|
||
def wash_single_car(self, car: Car) -> None: | ||
car.clean_mark = self.clean_power | ||
|
||
def rate_service(self, new_rating: int) -> None: | ||
total_ratings = self.average_rating * self.count_of_ratings | ||
self.count_of_ratings += 1 | ||
self.average_rating = round((total_ratings + new_rating) | ||
/ self.count_of_ratings, 1) |