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_Car_wash_station #766

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
47 changes: 43 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
from typing import Callable
class Car:
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


def cache(func: Callable) -> Callable:
# Write your code here
pass
class CarWashStation:
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:
return round(
sum(self.calculate_washing_price(single_car)
for single_car in cars
if self.wash_single_car(single_car))
)

def calculate_washing_price(self, single_car: Car) -> float:
return (
single_car.comfort_class * self.clean_power -
single_car.clean_mark * self.average_rating /
self.distance_from_city_center
)

def wash_single_car(self, single_car: Car) -> None:
if self.clean_power > single_car.clean_mark:
single_car.clean_mark = self.clean_power

def rate_service(self, rate: int):
self.average_rating = round(
(self.average_rating *
self.count_of_ratings + rate) /
(self.count_of_ratings + 1), 1
)
self.count_of_ratings += 1
Loading