-
Notifications
You must be signed in to change notification settings - Fork 701
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
create function shop trip and some classes #643
base: master
Are you sure you want to change the base?
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.
Good job.
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 on the code! While there are some minor improvements suggested, they don't impact the core 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! ✨
def calculate_road_cost(self, customer_loc: list, | ||
shop_loc: list, fuel_price: float) -> float: |
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 parameters 'customer_loc' and 'shop_loc' should have more descriptive names indicating that they are coordinates, such as 'customer_coordinates' and 'shop_coordinates'. This aligns with the checklist item: 'Use descriptive and correct variable names.'
def __init__(self, name: str, product_cart: dict, | ||
location: list, money: float, car: Car) -> None: |
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 variable name 'product_cart' could be more descriptive. Consider renaming it to something like 'shopping_cart' for better clarity.
self.car = car | ||
self.target_shop = None | ||
|
||
def calculate_all_cost(self, shops: list[Shop], fuel_price: float) -> None: |
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 method 'calculate_all_cost' has a descriptive name, but consider adding a docstring to explain its purpose and parameters for better readability.
# Find cheaper shop | ||
self.find_cheaper_shop(total_costs, shops) | ||
|
||
def find_cheaper_shop(self, total_costs: list, shops: list[Shop]) -> None: |
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 method 'find_cheaper_shop' could benefit from a docstring to clarify its functionality and parameters, enhancing code readability.
from app.car import Car | ||
from app.shop import Shop | ||
|
||
CONFIG_FILE = "config.json" |
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.
Make sure you write the correct path to the JSON file. The current path is relative and may not work if the script is executed from a different directory.
for customer in customers: | ||
print(f"{customer.name} has {customer.money} dollars") | ||
customer.calculate_all_cost(shops, info["FUEL_PRICE"]) | ||
if shop := customer.target_shop: |
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 use of the walrus operator (:=) is correct here, but ensure that it is supported in your Python version (Python 3.8+).
@@ -0,0 +1,27 @@ | |||
import datetime |
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 import statement is correct according to the checklist requirement: 'Make sure you use exactly import datetime
, not the other way of import.'
|
||
|
||
class Shop: | ||
def __init__(self, name: str, location: list, products: dict) -> None: |
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 parameter 'location' is typed as a list, but it might be more descriptive to specify the type of elements in the list, for example, List[str] or List[float], depending on what 'location' is supposed to represent.
self.location = location | ||
self.products = products | ||
|
||
def calculate_product_cost(self, product_cart: dict) -> list: |
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 return type hint for 'calculate_product_cost' is 'list', but it might be more descriptive to specify the type of elements in the list, for example, List[float] or List[int].
No description provided.