Skip to content

Commit

Permalink
Solution2
Browse files Browse the repository at this point in the history
  • Loading branch information
omnigun committed Oct 19, 2024
1 parent 97ec008 commit d6e7f88
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,26 @@ def __init__(
self.count_of_ratings = count_of_ratings

def serve_cars(self, cars: list) -> float:
if not cars or not len(cars):
if not cars:
return 0

summ = 0
total_price = 0
for car in cars:
if self.clean_power > car.clean_mark:
print(self.calculate_washing_price(car))
summ += self.calculate_washing_price(car)
total_price += self.calculate_washing_price(car)
self.wash_single_car(car)
return summ
return total_price

def calculate_washing_price(self, car: any) -> 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: any) -> None:
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, rate: int) -> None:
def rate_service(self, rate: Car) -> None:
rating = self.average_rating
count = self.count_of_ratings
new_rating = ((rating * count) + rate) / (count + 1)
Expand Down

0 comments on commit d6e7f88

Please sign in to comment.