Created
July 21, 2022 20:00
-
-
Save LaRevoltage/6e8238dcf52b48a6980ad0b2a4c47c14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Auto: | |
auto_count = 0 | |
user_car = [] | |
cars = [] | |
check_exist = False | |
def __init__(self, model,year, price): | |
self.model = model | |
self.year = year | |
self.price = price | |
Auto.auto_count += 1 | |
Auto.cars.append(self) | |
def print_count(): | |
print(f"there are {Auto.auto_count} cars in our store") | |
def find_car_by_year (user_needs_year): | |
for i in Auto.cars: | |
if i.year == user_needs_year: | |
Auto.user_car.append(i) | |
else: | |
return( f"there is no car {2022 - int(user_needs_year)} age in our store") | |
return(Auto.user_car) | |
#print(f"the rice for model {i.model} {i.year} year is {i.price} USD") | |
# Auto.check_exist = True | |
user_needs_year = "1999" | |
car1 = Auto("VW","1999",2300) | |
car2 = Auto("BMV","1999",5200) | |
car3 = Auto("Audi","1998",4500) | |
Auto.print_count() | |
Auto.find_car_by_year(user_needs_year) | |
result_search = Auto.find_car_by_year(user_needs_year) | |
print("There are following cars with requested age:") | |
for i in result_search: | |
print(i.model, i.year, i.price) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment