Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
omnigun committed Oct 19, 2024
1 parent 16d8349 commit 97ec008
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
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 serve_cars(self, cars: list) -> float:
if not cars or not len(cars):
return 0

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

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:
if self.clean_power > car.clean_mark:
car.clean_mark = self.clean_power

def rate_service(self, rate: int) -> None:
rating = self.average_rating
count = self.count_of_ratings
new_rating = ((rating * count) + rate) / (count + 1)

self.average_rating = round(new_rating, 1)
self.count_of_ratings += 1

0 comments on commit 97ec008

Please sign in to comment.