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

shop-trip #683

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

shop-trip #683

wants to merge 3 commits into from

Conversation

TrMaksym
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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:

  1. 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.
  2. Import Errors:

    • The import statement for the Shop class is incorrect. It should be from app.Shop import Shop.
    • There is a syntax error in the import statement. The correct syntax should be from typing import List, Dict.
  3. Type Consistency:

    • 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.

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 Show resolved Hide resolved
app/Shop.py Outdated

return round(total_cost, 2)

def is_product_available(self, product_cart):

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

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
Comment on lines 32 to 40
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

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
Comment on lines 82 to 83
for product, price in shop.products.items():
print(f"{product}: {price} dollars")

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

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.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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:

  1. Import Errors:

    • Ensure the import statement for the Shop class is from app.Shop import Shop.
    • Correct the import statement for typing to from typing import Dict.
  2. Functionality Issues:

    • 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.
    • The print_receipt function should print only the products that the customer actually purchased. Pass the shop object to the function and access shop.products instead.
    • 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.
  3. 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.

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

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

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

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)

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:

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

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)

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.

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.

2 participants