Skip to content

Commit

Permalink
done requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zazmarga committed Sep 4, 2024
1 parent 339725b commit a17e4bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
8 changes: 4 additions & 4 deletions app/car.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from math import dist


class Car:
def __init__(self, brand: str, fuel_consumption: float) -> None:
self.brand = brand
self.fuel_consumption = fuel_consumption

def calculate_required_fuel(self, location_a: list,
location_b: list) -> float:
x_a, y_a = location_a
x_b, y_b = location_b
distance = ((x_b - x_a) ** 2 + (y_b - y_a) ** 2) ** 0.5
return 2 * distance * self.fuel_consumption / 100
return 2 * dist(location_a, location_b) * self.fuel_consumption / 100
4 changes: 2 additions & 2 deletions app/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def go_to_the_shop(self, shop: Shop) -> None:
payment_by_check = shop.calculate_amount_purchase(self,
print_check=True)
self.money -= payment_by_check
print(f"{self.name} rides home")
print(f"{self.name} now has {round(self.money, 2)} dollars\n")
print(f"{self.name} rides home\n"
f"{self.name} now has {round(self.money, 2)} dollars\n")
self.location = home_location
5 changes: 2 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def shop_trip() -> None:
Shop(
shop["name"],
shop["location"],
[ProductShop(key, value) for key, value
[ProductShop(name, price) for name, price
in shop["products"].items()]
)
)
Expand All @@ -32,8 +32,7 @@ def shop_trip() -> None:
in customer["product_cart"].items()],
customer["location"],
customer["money"],
Car(customer["car"]["brand"],
customer["car"]["fuel_consumption"])
Car(**customer["car"])
)
)

Expand Down
14 changes: 6 additions & 8 deletions app/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ def calculate_amount_purchase(
) -> float:
result = 0
if print_check:
print("Date:",
datetime(2021, 1, 4, 12, 33, 41)
.strftime("%d/%m/%Y %H:%M:%S")
)
print(f"Thanks, {customer.name}, for your purchase!")
print("You have bought:")
print(f"Date: {datetime(2021, 1, 4, 12, 33, 41)
.strftime('%d/%m/%Y %H:%M:%S')}\n"
f"Thanks, {customer.name}, for your purchase!\n"
"You have bought:")
for each in customer.product_cart:
for product in self.products:
if each.name == product.name:
Expand All @@ -63,6 +61,6 @@ def calculate_amount_purchase(
print(f"{quantity} {product.name}{plural} "
f"for {amount_each} dollars")
if print_check:
print(f"Total cost is {round(result, 2)} dollars")
print("See you again!\n")
print(f"Total cost is {round(result, 2)} dollars\n"
"See you again!\n")
return round(result, 2)

0 comments on commit a17e4bb

Please sign in to comment.