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 #669

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

Solution #669

wants to merge 2 commits into from

Conversation

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

Great job on implementing the task requirements! 🎉 Your code is well-structured and meets the core functionality as described. While there are a few areas for potential improvement, such as optimizing calculations and ensuring consistency in method outputs, these are minor and do not impact the overall functionality. Keep up the good work and consider the feedback for future enhancements! 😊

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

Comment on lines +11 to +12
distance = sqrt((end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2)
return round(2 * distance * self.fuel_consumption / 100, 2)

Choose a reason for hiding this comment

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

The formula for calculating the total fuel consumption seems to assume a round trip (multiplying the distance by 2). If this is intentional, it's fine. Otherwise, if you only need the one-way consumption, you should remove the multiplication by 2.

shop: Shop,
fuel_price: float
) -> float:
products_cost = shop.products_cost(self.product_cart).values()

Choose a reason for hiding this comment

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

The products_cost method returns a dictionary, but you are calling .values() on it, which returns a view object. Ensure that this is intended, as you later sum these values. If products_cost is expected to return a total cost, consider modifying the method to return a single float value instead of a dictionary.

fuel_price: float
) -> float:
products_cost = shop.products_cost(self.product_cart).values()
fuel_cons = self.car.total_consumption(self.location, shop.location)

Choose a reason for hiding this comment

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

The total_consumption method in the Car class calculates the round trip fuel consumption. Ensure that this aligns with your requirement to calculate the cost for a round trip, as per the task description.

print(f"{self.name}'s trip to the {shop.name} costs {trip_cost}")
trips_cost.append(trip_cost)
cheapest_trip_index = trips_cost.index(min(trips_cost))
return shops[cheapest_trip_index], trips_cost[cheapest_trip_index]

Choose a reason for hiding this comment

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

Ensure that the cheapest_trip method returns both the shop and the cost correctly. The tuple return type (Shop, float) seems appropriate, but verify that the logic correctly identifies the cheapest trip.

fuel_price = data["FUEL_PRICE"]

for customer in data["customers"]:
current_customer = Customer(*customer.values())

Choose a reason for hiding this comment

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

Ensure that the Customer class constructor is correctly handling the unpacked values from the customer dictionary. The order of values should match the parameters expected by the Customer class constructor.


for customer in data["customers"]:
current_customer = Customer(*customer.values())
shops = [Shop(*shop.values()) for shop in data["shops"]]

Choose a reason for hiding this comment

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

Similarly, ensure that the Shop class constructor is correctly handling the unpacked values from the shop dictionary. The order of values should match the parameters expected by the Shop class constructor.

f"doesn't have enough money to make a purchase in any shop")
else:
print(f"{current_customer.name} rides to {shop.name}\n")
shop.shopping(current_customer.name, current_customer.product_cart)

Choose a reason for hiding this comment

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

The shopping method in the Shop class should correctly handle the purchase process. Ensure that the method is implemented to print the purchase receipt and update any necessary state.

products: dict

def products_cost(self, cart: dict) -> dict:
return {

Choose a reason for hiding this comment

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

The products_cost method returns a dictionary of product costs. Ensure that this aligns with how you intend to use these costs in other parts of the application, as seen in customer.py.

Comment on lines +25 to +26
print(f"{cart[product]} {product}s for "
f"{self.round_price(products_cost[product])} dollars")

Choose a reason for hiding this comment

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

Consider storing the result of self.products_cost(cart).values() in a variable to avoid recalculating it multiple times. This will improve readability and efficiency.


print(f"Total cost is {sum(self.products_cost(cart).values())}"
f" dollars")
print("See you again!\n")

Choose a reason for hiding this comment

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

The round_price method is designed to return an integer if the price is a whole number. Ensure that this behavior is intended, as it might affect how prices are displayed in the shopping receipt.

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