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

created shop trip func #589

Closed
wants to merge 6 commits into from
Closed

created shop trip func #589

wants to merge 6 commits into from

Conversation

Timur5050
Copy link

No description provided.

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

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

Several changes were requested

Comment on lines +13 to +14
with open("app/config.json", "r") as file_info:
all_info = json.load(file_info)

Choose a reason for hiding this comment

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

Do not overload a context manage, perform only load operation within it.

app/main.py Outdated
Comment on lines 46 to 55
cost_for_trip = round(
2 * customer.car.calculate_trip_cost(
customer.car.calculate_distance(
customer.location,
shop.location
),
fuel_price
)
+ shop.calculate_cost_for_products(customer.product_cart)
, 2)

Choose a reason for hiding this comment

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

In case there are no arguments on the same line with an opening parenthesis, your closing parenthesis should not have any arguments on the same line as well. Please, resolve this issue

app/main.py Outdated
f"doesn't have enough money to make a purchase in any shop")
else:
chippest_shop = list(costs_for_trips.keys())[
list(costs_for_trips.values()).index(

Choose a reason for hiding this comment

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

Leave no arguments for closing parenthesis as it is don for an opening one

app/shops.py Outdated
Comment on lines 21 to 25
total_sum = 0
for product in product_cart:
total_sum += product_cart[product] * self.products[product]

return total_sum

Choose a reason for hiding this comment

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

You could use sum and generator expression here

app/config.json Outdated
@@ -73,4 +73,4 @@
}
}
]
}
}

Choose a reason for hiding this comment

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

Add a blank line at the end of the file here

app/main.py Outdated
print(f"{customer.name} "
f"doesn't have enough money to make a purchase in any shop")
else:
chippest_shop = list(costs_for_trips.keys())[

Choose a reason for hiding this comment

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

Please find another, simple way to find chippest_shop
Maybe you can do it during iteration over list_of_shops

@Timur5050 Timur5050 requested a review from pavlopro June 17, 2024 14:44
Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

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

LGTM, well done! One comment is left for conisderation

f"now has {customer.money} dollars\n")


shop_trip()

Choose a reason for hiding this comment

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

Place the function calls in the file inside of the if __name__ == "__main__" block in the future

@Timur5050 Timur5050 closed this by deleting the head repository Jul 1, 2024
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