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

create function shop trip and some classes #643

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

Conversation

Mxbely
Copy link

@Mxbely Mxbely commented Oct 16, 2024

No description provided.

Copy link

@vladyslav-tmf vladyslav-tmf left a comment

Choose a reason for hiding this comment

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

Good job.

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

Comment on lines +9 to +10
def calculate_road_cost(self, customer_loc: list,
shop_loc: list, fuel_price: float) -> float:

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

Comment on lines +6 to +7
def __init__(self, name: str, product_cart: dict,
location: list, money: float, car: Car) -> None:

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:

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:

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"

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:

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

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:

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:

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

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.

3 participants