-
Notifications
You must be signed in to change notification settings - Fork 740
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
shop-trip #683
base: master
Are you sure you want to change the base?
shop-trip #683
Conversation
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.
Thank you for your hard work on this project! While your implementation is on the right track, there are a few critical issues that need to be addressed before we can approve the pull request:
-
Functionality Issues:
- The
choose_cheapest_store
method currently only considers the trip cost. It should also include the cost of the products to ensure accurate calculations. - The
print_receipt
function should only print the products that the customer actually purchased, not all products available in the shop.
- The
-
Import Errors:
- The import statement for the
Shop
class is incorrect. It should befrom app.Shop import Shop
. - There is a syntax error in the import statement. The correct syntax should be
from typing import List, Dict
.
- The import statement for the
-
Type Consistency:
- The
is_product_available
method should specify the type for theproduct_cart
parameter to maintain consistency. Consider usingDict[str, int]
as the type hint.
- The
These changes are necessary to ensure that the code functions correctly and aligns with the task requirements. Once these issues are resolved, we can proceed with the approval. Keep up the great work, and don't hesitate to reach out if you need any help! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
app/Shop.py
Outdated
|
||
return round(total_cost, 2) | ||
|
||
def is_product_available(self, product_cart): |
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.
The is_product_available
method should specify the type for the product_cart
parameter to maintain consistency. Consider using Dict[str, int]
as the type hint, similar to the calculate_purchase_cost
method.
import math | ||
from typing import List, Dict | ||
|
||
from app import Shop |
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.
The import statement for the Shop
class is incorrect. It should be from app.Shop import Shop
to correctly import the Shop
class from the Shop.py
file.
app/customer.py
Outdated
def choose_cheapest_store(self, shops: Dict[str, Shop], fuel_price: float) -> str: | ||
cheapest_store = None | ||
lowest_price = float("inf") | ||
for shop_name, shop in shops.items(): | ||
price = self.calculate_trip_cost(shop.location, fuel_price) | ||
if price < lowest_price: | ||
lowest_price = price | ||
cheapest_store = shop_name | ||
return cheapest_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.
The choose_cheapest_store
method currently calculates the cheapest store based only on the trip cost. According to the task description, the total cost should include both the trip cost and the cost of the products. Consider modifying the logic to include the product purchase cost in the calculation.
app/main.py
Outdated
for product, price in shop.products.items(): | ||
print(f"{product}: {price} dollars") |
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.
The print_receipt
function currently prints all products available in the shop, not just the ones purchased. Modify this to only print the products that the customer actually bought, using the product_cart
from the Customer
instance.
for shop_name, shop in shops.items(): | ||
trip_cost = customer.calculate_trip_cost(shop.location, fuel_price) | ||
purchase_cost = shop.calculate_purchase_cost(customer.product_cart) | ||
total_cost = trip_cost * 2 + purchase_cost |
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.
Ensure that the total cost calculation includes both the trip cost (to and from the shop) and the purchase cost. This line correctly calculates it, but ensure that the logic aligns with the task description, which specifies these components.
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 job on making significant progress with your code! 🎉 While the Pull Request is approved to help you move forward with your learning journey, there are a few critical issues that need your attention:
-
Import Errors:
- Ensure the import statement for the
Shop
class isfrom app.Shop import Shop
. - Correct the import statement for typing to
from typing import Dict
.
- Ensure the import statement for the
-
Functionality Issues:
- The
calculate_purchase_cost
method should be called on theshop
object, notself
. Ensure you pass the correct parameters to calculate the total cost. - The
print_receipt
function should print only the products that the customer actually purchased. Pass theshop
object to the function and accessshop.products
instead. - The
print_receipt
function should not haveself
as a parameter since it is not a method of a class. It should take parameters likecustomer_name
,shop
, andpurchase_cost
.
- The
-
Constructor and Syntax:
- Ensure the
Shop
constructor arguments are in the correct order:Shop(shop_name, products, shop_location)
. - Remove any unnecessary backslashes at the end of lines to avoid syntax errors.
- Ensure the
These adjustments will enhance the functionality and readability of your code. Keep up the great work, and remember to address these issues to avoid similar problems in the future. Happy coding! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -0,0 +1,22 @@ | |||
from typing import Dict |
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.
There is a syntax error in the import statement. The correct syntax should be from typing import Dict
without the slash.
import math | ||
from typing import Dict | ||
|
||
from app import Shop |
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.
The import statement for the Shop
class is incorrect. It should be from app.Shop import Shop
to match the correct file structure and class name.
self.car = car | ||
|
||
def add_to_cart(self, product: str, quantity: int) -> None: | ||
self.product_cart[product]\ |
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.
There is an unnecessary backslash at the end of this line. It should be removed to avoid syntax errors.
shop_name = shop_data["name"] | ||
shop_location = tuple(shop_data["location"]) | ||
products = shop_data["products"] | ||
shops[shop_name] = Shop(shop_name, shop_location, products) |
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.
The Shop
constructor arguments are in the wrong order. It should be Shop(shop_name, products, shop_location)
to match the Shop
class definition.
print(f"{customer.name} now has {customer.money: .2f} dollars\n") | ||
|
||
|
||
def print_receipt(self) -> None: |
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.
The print_receipt
function should not have self
as a parameter since it is not a method of a class. It should take parameters like customer_name
, shop
, and purchase_cost
instead.
for product, quantity in self.product_cart.items(): | ||
if quantity > 0: | ||
print(f"{quantity} {product}(s)" | ||
f" for {self.products[product] * quantity} dollars") |
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.
The print_receipt
function is trying to access self.products
, which does not exist. You should pass the shop
object to the function and access shop.products
instead.
print(f"{quantity} {product}(s)" | ||
f" for {self.products[product] * quantity} dollars") | ||
|
||
total_cost = self.calculate_purchase_cost(self.product_cart) |
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.
The calculate_purchase_cost
method should be called on the shop
object, not self
. Ensure you pass the correct parameters to calculate the total cost.
No description provided.