-
Notifications
You must be signed in to change notification settings - Fork 696
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
The solution of the task #597
base: master
Are you sure you want to change the base?
Conversation
app/main.py
Outdated
def shop_trip() -> None: | ||
with open("app/config.json", "r") as f: | ||
data = json.load(f) | ||
fuel_price = data["FUEL_PRICE"] |
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.
Do not overload context manager
Start retrieving data outside context manager
app/main.py
Outdated
people["car"]["fuel_consumption"]) | ||
) | ||
print(f"{customer.name} has {customer.money} dollars") | ||
prices = [] |
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.
from task requirements:
When the customer arrives at the shop his location should equal to shop location. After the shop he arrives home and counts the remaining money.
app/main.py
Outdated
Car(people["car"]["brand"], | ||
people["car"]["fuel_consumption"]) |
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.
Car(people["car"]["brand"], | |
people["car"]["fuel_consumption"]) | |
Car(**people["car"]) |
you can use unpacking in this case
app/main.py
Outdated
distance = math.dist(customer.location, shop.location) | ||
cost = round(shop.trip_cost(distance, fuel_price, customer), 2) |
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.
DRY
don'е repeat yourself
app/main.py
Outdated
distance = math.dist(customer.location, current_shop.location) | ||
current_shop.print_receipt(customer) | ||
print(f"{customer.name} rides home") | ||
customer.money -= round( | ||
current_shop.trip_cost(distance, fuel_price, customer), 2 | ||
) |
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.
DRY
you are double counting the distance and price of products for the same store
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.
Great!
No description provided.