-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #1644
base: master
Are you sure you want to change the base?
Solution #1644
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotta be to blank lines between classes |
||
class CarWashStation: | ||
# write your code here | ||
pass | ||
def __init__(self, distance_from_city_center, clean_power, average_rating, count_of_ratings): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type annotations for 'distance_from_city_center'. 'clean_power'. 'average_rating'. 'count_of_ratings' and return type for init method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line's too long. you can put each parameter on separate line |
||
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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type annotation for 'cars' and return type for the function |
||
total_income = 0 | ||
for car in cars: | ||
if car.clean_mark < self.clean_power: | ||
total_income += self.calculate_washing_price(car) | ||
car.clean_mark = self.clean_power | ||
return round(total_income, 1) | ||
|
||
def calculate_washing_price(self, car): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type annotation for 'car' and return type for the function |
||
price = (car.comfort_class * (self.clean_power - car.clean_mark) * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W504 line break after binary operator. Google how to fix it |
||
self.average_rating) / self.distance_from_city_center | ||
return round(price, 1) | ||
|
||
def wash_single_car(self, car): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type annotation for 'car' and return type for the function |
||
if car.clean_mark < self.clean_power: | ||
car.clean_mark = self.clean_power | ||
|
||
def rate_service(self, rating): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add type annotation for 'raiting' and return type for the function |
||
self.count_of_ratings += 1 | ||
self.average_rating = round(((self.average_rating * (self.count_of_ratings - 1)) + rating) / self.count_of_ratings, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. divide this line into several |
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unnecessary blank lines |
||
|
||
bmw = Car(comfort_class=3, clean_mark=3, brand='BMW') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change single quotes into double quotes |
||
audi = Car(comfort_class=4, clean_mark=9, brand='Audi') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change single quotes into double quotes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix trailing whitespace |
||
|
||
print(bmw.clean_mark) | ||
|
||
|
||
wash_station = CarWashStation( | ||
distance_from_city_center=5, | ||
clean_power=6, | ||
average_rating=3.5, | ||
count_of_ratings=6 | ||
) | ||
|
||
|
||
income = wash_station.serve_cars([bmw, audi]) | ||
print(income) # 6.3 | ||
print(bmw.clean_mark) # 6 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add type annotations for "comfort_class", "clean_mark", "brand" and return type for init method