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

The solution of the task #597

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

The solution of the task #597

wants to merge 4 commits into from

Conversation

Ja0ni
Copy link

@Ja0ni Ja0ni commented Jul 14, 2024

No description provided.

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"]

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 = []

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.

@Ja0ni Ja0ni requested a review from pavlopro July 21, 2024 21:53
app/main.py Outdated
Comment on lines 21 to 22
Car(people["car"]["brand"],
people["car"]["fuel_consumption"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Car(people["car"]["brand"],
people["car"]["fuel_consumption"])
Car(**people["car"])

you can use unpacking in this case

app/main.py Outdated
Comment on lines 27 to 28
distance = math.dist(customer.location, shop.location)
cost = round(shop.trip_cost(distance, fuel_price, customer), 2)
Copy link
Contributor

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
Comment on lines 38 to 43
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
)
Copy link
Contributor

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

@Ja0ni Ja0ni requested a review from vsmutok July 22, 2024 22:52
Copy link
Contributor

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

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

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants