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

Solution #685

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

Solution #685

wants to merge 5 commits into from

Conversation

yvespy
Copy link

@yvespy yvespy commented Jan 16, 2025

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 code is mostly well-implemented and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Shop Class Initialization: The products parameter should be a dictionary, not a string. This is crucial for the functionality of the Shop class, as it affects how product prices are accessed and calculated.

  2. shop_trip Function: The calculation of distance_to_home is incorrect. It currently calculates the distance from the customer's location to itself, which will always be zero. This needs to be corrected to calculate the distance from the shop back to the customer's original location.

  3. String Formatting: There is a syntax error in the print statement due to incorrect usage of double quotes inside an f-string. Please use single quotes around the format string or escape the double quotes to fix this issue.

  4. Customer Class: The new_location parameter is expected to be a list, but it is being treated as a string. Ensure that new_location is a list with the correct format to avoid potential errors.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you have any questions or need further clarification. 😊

✨ 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/customer.py Outdated
Comment on lines 32 to 34
new_location: str) -> None:
self.money -= total_cost
self.location = new_location

Choose a reason for hiding this comment

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

The new_location parameter is expected to be a list (similar to self.location), but it is being treated as a string. Ensure that new_location is a list with the correct format.

app/customer.py Outdated
shop_name: str,
purchased_products: dict,
total_cost: float) -> None:
print(f"\nDate: {datetime.now().strftime("%d/%m/%Y %H:%M:%S")}")

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 print statement due to incorrect usage of double quotes inside an f-string. Use single quotes around the format string or escape the double quotes.

app/main.py Outdated

for shop in shop_objects:
distance_to_shop = customer.calculate_distance(shop.location)
distance_to_home = customer.calculate_distance(customer.location)

Choose a reason for hiding this comment

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

The calculation of distance_to_home is incorrect. It currently calculates the distance from the customer's location to itself, which will always be zero. You should calculate the distance from the shop back to the customer's original location.

app/main.py Outdated
Comment on lines 52 to 53
total_trip_cost \
= fuel_cost_to_shop + product_cost + fuel_cost_to_home

Choose a reason for hiding this comment

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

The line continuation character \ is unnecessary here because the expression is already within parentheses. You can safely remove it.

app/shop.py Outdated
@@ -0,0 +1,15 @@
class Shop:
def __init__(self, name: str, location: str, products: str) -> None:

Choose a reason for hiding this comment

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

The products parameter should be a dictionary, not a string. Update the type hint and ensure that the products parameter is passed as a dictionary when creating a Shop instance.

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 addressing the previous issues! 🎉 Your code now meets the task requirements and constraints. Here are some important points to consider for future improvements:

  • Customer Class and make_customer_list Function: Ensure that customer['product_cart'] is consistently a dictionary, as this is crucial for the functionality of the product_cart attribute.

  • Distance Calculation: Verify that the use of math.dist and the division by 100 in the road cost calculation align with your application's requirements, especially regarding the units of measurement.

  • File Paths and Data: Double-check that the path to app/config.json is correct and that the file contains all necessary data for the shop_trip function.

  • Consistency in Data Structures: Ensure that the products parameter in the Shop class is consistently a dictionary throughout the code.

  • Location Format: Confirm that the location attribute in the Customer class is a list in the correct format (e.g., [latitude, longitude]).

These improvements will help you avoid similar issues in the future. Keep up the good work, and continue learning from your experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

class Customer:
name: str
product_cart: dict
location: list

Choose a reason for hiding this comment

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

The location attribute is expected to be a list, which is correct. However, ensure that the list contains the correct format (e.g., [latitude, longitude]) as per your application's requirements.

customers.append(
Customer(
customer["name"],
customer["product_cart"],

Choose a reason for hiding this comment

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

Ensure that customer['product_cart'] is a dictionary as expected by the Customer class. This is crucial for the functionality of the product_cart attribute.



def shop_trip() -> None:
with open("app/config.json", "r") as f:

Choose a reason for hiding this comment

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

Ensure that the path to app/config.json is correct and that the file contains all necessary data as expected by the shop_trip function.

def __init__(self,
name: str,
location: list,
products: dict,

Choose a reason for hiding this comment

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

The products parameter in the Shop class should be a dictionary, which is correct. Ensure that this is consistently a dictionary throughout the code.

def calculate_road_cost(customer: Customer,
shop: Shop, fuel_price: float) -> float:
return round(
math.dist(customer.location, shop.location) / 100

Choose a reason for hiding this comment

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

The calculation of the road cost is correct, but ensure that the distance calculation (math.dist) is appropriate for your application's requirements. The division by 100 assumes the distance is in meters; adjust if necessary.


print(f"{customer.name}'s trip to the {shop.name} costs {trip_cost}")

if trip_cost < customer.money and trip_cost <= cheapest_trip_cost:

Choose a reason for hiding this comment

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

The condition checks if the trip cost is less than the customer's money, which is correct. Ensure that the logic here aligns with the task requirements for determining if a customer can afford the trip.



def go_to_home(customer: Customer) -> None:
customer.money -= customer.trip_cost

Choose a reason for hiding this comment

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

Ensure that the subtraction of customer.trip_cost from customer.money is correct and that customer.trip_cost includes all necessary costs (products and road).

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