Skip to content

Commit

Permalink
Fixed flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pnakonechniy committed Aug 2, 2023
1 parent c068044 commit 24b0279
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
12 changes: 8 additions & 4 deletions app/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ def __init__(self, brand: str, fuel_consumption: int | float) -> None:
self.brand = brand
self.fuel_consumption = fuel_consumption

def calculate_fuel_cost(self, first_location: list, second_location: list, fuel_price: float) -> float:

distance = ((first_location[0] - second_location[0]) ** 2 +
(first_location[1] - second_location[1]) ** 2) ** 0.5
def calculate_fuel_cost(
self,
first_point: list,
second_point: list,
fuel_price: float
) -> float:
distance = ((first_point[0] - second_point[0]) ** 2 + (
first_point[1] - second_point[1]) ** 2) ** 0.5

return (self.fuel_consumption / 100) * distance * fuel_price * 2
15 changes: 12 additions & 3 deletions app/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ def __init__(
self.enough_money = False
self.total_cost = 0

def choose_the_best_shop(self, shops_list: List[Shop], fuel_price: float) -> None:
def choose_the_best_shop(
self,
shops_list: List[Shop],
fuel_price: float
) -> None:
shops = {}
for shop in shops_list:
costs_of_product = shop.calculate_amount_for_products(self.product_cart)
costs_of_product = shop.calculate_amount_for_products(
self.product_cart
)
fuel_cost = self.car.calculate_fuel_cost(
self.location, shop.location, fuel_price
)
Expand All @@ -47,7 +53,10 @@ def ride_to_the_shop(self) -> None:
print(f"{self.name} rides to {self.cheapest_shop.name}\n")
self.location = self.cheapest_shop.location
else:
print(f"{self.name} doesn't have enough money to make a purchase in any shop")
print(
f"{self.name} doesn't have enough "
f"money to make a purchase in any shop"
)

def buy_products(self) -> None:
if self.enough_money:
Expand Down
9 changes: 6 additions & 3 deletions app/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ def calculate_amount_for_products(self, product_cart: dict) -> int | float:

def print_bill(self, product_cart: dict, name: str) -> float:

print(f"Date: {datetime.datetime.now().strftime('%d/%m/%Y %H:%M:%S')}\n"
f"Thanks, {name}, for your purchase!\n"
"You have bought: ")
print(
f"Date: "
f"{datetime.datetime.now().strftime('%d/%m/%Y %H:%M:%S')}\n"
f"Thanks, {name}, for your purchase!\n"
"You have bought: "
)

total_amount = 0
for product_name, count in product_cart.items():
Expand Down

0 comments on commit 24b0279

Please sign in to comment.