-
Notifications
You must be signed in to change notification settings - Fork 735
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
base: master
Are you sure you want to change the base?
Solution #677
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.
Great job. If you don't mind I'd rather you'll check my repo and give me some advices for improving it
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 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:
-
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 inapp/main.py
. Please ensure thatcustomer.location
is updated totarget_shop.location
after the purchase. -
Car Dictionary Validation: In the
Customer
class withinapp/customer.py
, thecar
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 theCar
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"]) |
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 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" |
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.
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.
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.
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 theCustomer
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 thebrand
andfuel_consumption
parameters in theCar
class constructor. Ensuringbrand
is a non-empty string andfuel_consumption
is a positive number will help initialize theCar
object with valid data. -
Cash Register Improvements: Ensure the loop iterates over
number_of_products
instead ofproduct_prices
to avoid issues with missing products. Also, consider usingdatetime.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! ✨
def __init__( | ||
self, | ||
brand: str, | ||
fuel_consumption: float | ||
) -> None: | ||
self.brand = brand | ||
self.fuel_consumption = fuel_consumption |
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.
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.
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"]) |
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.
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 |
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 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.
2021, 1, 4, 12, 33, 41 | ||
).strftime("%d/%m/%Y %H:%M:%S") |
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 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.
for product in product_prices: | ||
plural = "" | ||
if number_of_products[product] > 1: | ||
plural = "s" | ||
if product in number_of_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.
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.
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.
Well done!
No description provided.