Code Monkey home page Code Monkey logo

py-car-wash-station's Introduction

Washing Station

Read the guideline before starting.

You own a car washing station. Washing cost calculation takes a lot of time, and you decide to automate this calculation. The washing cost will depend on car comfort class, car cleanness degree, wash station average rating and wash station distance from the center of the city.

Create class Car, its __init__ method takes and stores 3 arguments:

  1. comfort_class - comfort class of a car, from 1 to 7
  2. clean_mark - car cleanness mark, from very dirty - 1 to absolutely clean - 10
  3. brand - brand of the car

Create class CarWashStation, its __init__ method takes and stores 4 arguments:

  1. distance_from_city_center - how far station from the city center, from 1.0 to 10.0
  2. clean_power - clean_mark to which this car wash station washes (yes, not all stations can clean your car completely)
  3. average_rating - average rating of the station, from 1.0 to 5.0, rounded to 1 decimal
  4. count_of_ratings - number of people who rated

CarWashStation should have such methods:

  1. serve_cars - method, that takes a list of Car's, washes only cars with clean_mark < clean_power of wash station and returns income of CarWashStation for serving this list of Car's, rounded to 1 decimal:
bmw = Car(comfort_class=3, clean_mark=3, brand='BMW')
audi = Car(comfort_class=4, clean_mark=9, brand='Audi')

print(bmw.clean_mark)  # 3

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

So, only bmw was washed, because audi.clean_mark > wash_station.clean_power, and bmw.clean_mark has changed, because we washed it.

If audi.clean_mark was below wash_station.clean_power then audi would have been washed as well and the income would have raised:

bmw = Car(comfort_class=3, clean_mark=3, brand='BMW')
audi = Car(comfort_class=4, clean_mark=2, brand='Audi')

print(bmw.clean_mark)  # 3
print(audi.clean_mark) # 2

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)  # 17.5

print(bmw.clean_mark)  # 6
print(audi.clean_mark) # 6
  1. calculate_washing_price - method, that calculates cost for a single car wash, cost is calculated as: car's comfort class * difference between wash station's clean power and car's clean mark * car wash station rating / car wash station distance to the center of the city, returns number rounded to 1 decimal;
  2. wash_single_car - method, that washes a single car, so it should have clean_mark equals wash station's clean_power, if wash_station.clean_power is greater than car.clean_mark;
  3. rate_service - method that adds a single rate to the wash station, and based on this single rate average_rating and count_of_ratings should be changed:
wash_station = CarWashStation(
    distance_from_city_center=6,
    clean_power=8,
    average_rating=3.9,
    count_of_ratings=11
)

print(wash_station.average_rating)    # 3.9
print(wash_station.count_of_ratings)  # 11

wash_station.rate_service(5)

print(wash_station.average_rating)    # 4.0
print(wash_station.count_of_ratings)  # 12

You can add own methods if you need.

Example:

bmw = Car(3, 3, 'BMW')
audi = Car(4, 9, 'Audi')
mercedes = Car(7, 1, 'Mercedes')

ws = CarWashStation(6, 8, 3.9, 11)

income = ws.serve_cars([
    bmw,
    audi,
    mercedes
])

income == 41.7

bmw.clean_mark == 8
audi.clean_mark == 9  
mercedes.clean_mark == 8
# audi wasn't washed
# all other cars are washed to '8'

ford = Car(2, 1, 'Ford')
wash_cost = ws.calculate_washing_price(ford)  
# only calculating cost, not washing
wash_cost == 9.1
ford.clean_mark == 1 

ws.rate_service(5)

ws.count_of_ratings == 12
ws.average_rating == 4.0

Note: Check your code using this checklist before pushing your solution.

py-car-wash-station's People

Contributors

abnormaltype avatar danylott avatar dmytrosvirsa avatar ihor-jpeg avatar masterpieceelbow avatar y-havryliv avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.