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

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

Solution #677

wants to merge 3 commits into from

Conversation

ruslanyemets
Copy link

No description provided.

Copy link

@Dogober Dogober 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. If you don't mind I'd rather you'll check my repo and give me some advices for improving it

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 Pull Request! 😊 While your code meets most of the task requirements, there are a couple of critical issues that need to be addressed before we can approve it:

  1. Customer Location Update: After the customer visits a shop, their location should be updated to the shop's location. This is crucial for the functionality of the shop_trip function in app/main.py. Please ensure that customer.location is updated to target_shop.location after the purchase.

  2. Car Dictionary Validation: In the Customer class within app/customer.py, the car parameter should be validated to ensure it contains the necessary keys, such as 'brand' and 'fuel_consumption'. Adding validation or error handling will prevent potential issues during the initialization of the Car object.

Once these issues are resolved, your code will be in great shape! Keep up the excellent work, and feel free to reach out if you have any questions or need further assistance. 🚀

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

self.products_to_buy = products_to_buy
self.location = location
self.money = money
self.car = Car(car["brand"], car["fuel_consumption"])

Choose a reason for hiding this comment

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

Ensure that the car dictionary contains the keys 'brand' and 'fuel_consumption' before initializing the Car object. Consider adding validation or error handling to manage cases where these keys might be missing.

f"{cost_of_trips}"
f"{customer.name} rides to {target_shop.name}\n\n"
f"{purchase_receipt}\n"
f"{customer.name} rides home\n"

Choose a reason for hiding this comment

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

According to the task description, after the customer arrives at the shop, their location should be updated to the shop's location. Consider adding a line to update customer.location to target_shop.location after the purchase is made.

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.


Review Summary

Great effort on implementing the solution! 🎉 Your code meets the task requirements and constraints, and you've addressed some of the previous issues effectively. Here are a few points to consider for further improvement:

  • Customer Location Update: Well done on updating the customer's location after a purchase in the shop_trip function. This aligns with the task requirements and ensures correct functionality.

  • Car Dictionary Validation: It's important to validate the car dictionary in the Customer class to ensure it contains necessary keys like 'brand' and 'fuel_consumption'. This will prevent potential errors from malformed dictionaries.

  • Parameter Validation in Car Class: Consider adding validation for the brand and fuel_consumption parameters in the Car class constructor. Ensuring brand is a non-empty string and fuel_consumption is a positive number will help initialize the Car object with valid data.

  • Cash Register Improvements: Ensure the loop iterates over number_of_products instead of product_prices to avoid issues with missing products. Also, consider using datetime.now() for the purchase date to make the receipt more accurate.

Your decision to approve the Pull Request is to help you move forward with your learning. Please review the comments to improve your code, and address any critical issues in future projects to avoid similar problems. Keep up the great work and continue learning from these experiences! 🚀

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

Comment on lines +5 to +11
def __init__(
self,
brand: str,
fuel_consumption: float
) -> None:
self.brand = brand
self.fuel_consumption = fuel_consumption

Choose a reason for hiding this comment

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

Consider adding validation for the brand and fuel_consumption parameters in the __init__ method. This will ensure that the Car object is initialized with valid data. For example, you could check that brand is a non-empty string and fuel_consumption is a positive number.

Comment on lines +11 to +17
car: dict
) -> None:
self.name = name
self.products_to_buy = products_to_buy
self.location = location
self.money = money
self.car = Car(car["brand"], car["fuel_consumption"])

Choose a reason for hiding this comment

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

It's important to validate the car dictionary to ensure it contains the necessary keys, such as 'brand' and 'fuel_consumption', before initializing the Car object. Consider adding checks to verify the presence of these keys and handle cases where they are missing to avoid potential errors.

customer.products_to_buy,
target_shop.product_prices
)
customer.location = target_shop.location

Choose a reason for hiding this comment

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

Great job updating the customer's location to the shop's location after the purchase. This ensures that the customer's location is correctly updated after visiting the shop, as required by the task.

Comment on lines +23 to +24
2021, 1, 4, 12, 33, 41
).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.

The purchase date is currently hardcoded to a specific date and time. Consider using datetime.now() to dynamically generate the current date and time for the purchase receipt, which will make the receipt more accurate and relevant.

Comment on lines +32 to +36
for product in product_prices:
plural = ""
if number_of_products[product] > 1:
plural = "s"
if product in number_of_products:

Choose a reason for hiding this comment

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

Ensure that the loop iterates over number_of_products instead of product_prices to avoid potential issues when a product is not present in number_of_products. This will ensure that only purchased products are included in the receipt.

Copy link

@L1nk3rrr L1nk3rrr left a comment

Choose a reason for hiding this comment

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

Well done!

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.

4 participants