Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
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:
income = 0
for car in cars:
if car.clean_mark < self.clean_power:
income += self.calculate_washing_price(car)
self.wash_single_car(car)
final_income = round(income, 1)
return final_income

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirements state that this method should return the price rounded to 1 decimal place. Currently, the raw unrounded value is being returned.


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_score = self.average_rating * self.count_of_ratings
self.count_of_ratings += 1
new_average = (total_score + new_rating) / self.count_of_ratings
self.average_rating = round(new_average, 1)