Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #1742

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
43 changes: 39 additions & 4 deletions app/main.py
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_ratings: float) -> None:

Choose a reason for hiding this comment

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

The count_of_ratings parameter should be of type int instead of float, as it represents a count of ratings, which is inherently an integer value.

self.distance_from_city_center = round(distance_from_city_center, 1)
self.clean_power = clean_power
self.average_rating = round(average_rating, 1)
self.count_of_ratings = round(count_of_ratings, 1)

def serve_cars(self, cars: list[Car]) -> float:
full_washing_price = 0.0
for car in cars:
if car.clean_mark < self.clean_power:
full_washing_price += self.calculate_washing_price(car)
self.wash_single_car(car)
return round(full_washing_price, 1)

def calculate_washing_price(self, car: Car) -> 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: Car) -> None:
car.clean_mark = self.clean_power

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

Choose a reason for hiding this comment

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

Consider adding validation to ensure that the rating parameter is within a valid range (e.g., 1 to 5). This will prevent invalid ratings from affecting the average rating calculation.

Loading