Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Killreel committed Jan 15, 2025
1 parent 16d8349 commit 7983416
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
class Car:
# write your code here
pass
def __init__(self, comfort_class, clean_mark, brand):
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, clean_power, average_rating, count_of_ratings):
self.distance_from_city_center = distance_from_city_center
self.clean_power = clean_power
self.average_rating = round(average_rating, 1)
self.count_of_ratings = count_of_ratings

def calculate_washing_price(self, car):
price = (
car.comfort_class
* (self.clean_power - car.clean_mark)
* self.average_rating
/ self.distance_from_city_center
)
return round(price, 1)

def wash_single_car(self, car):
if car.clean_mark < self.clean_power:
car.clean_mark = self.clean_power

def serve_cars(self, cars):
total_income = 0.0
for car in cars:
if car.clean_mark < self.clean_power:
total_income += self.calculate_washing_price(car)
self.wash_single_car(car)
return round(total_income, 1)

def rate_service(self, new_rating):
total_rating = self.average_rating * self.count_of_ratings
self.count_of_ratings += 1
self.average_rating = round((total_rating + new_rating) / self.count_of_ratings, 1)

0 comments on commit 7983416

Please sign in to comment.