def main(): fender = Guitar("Fender", 1922, 5000) Air = Guitar("Air", 2011, 1) print(Guitar.get_age(fender)) print(Guitar.get_age(Air)) print(Guitar.is_vintage(fender)) print(Guitar.is_vintage(Air))
def main(): guitar_one = Guitar("Gibson L-5 Ces", 1922, 10000) guitar_two = Guitar("Second Guitar", 2011, 50) print("{}\n{}".format(guitar_one, guitar_two)) print("get_age() - Expected 94. Got {}".format(guitar_one.get_age())) print("get_age() - Expected 5. Got {}".format(guitar_two.get_age())) print("is_vintage() - Expected True. Got {}".format(guitar_one.is_vintage())) print("is_vintage() - Expected False. Got {}".format(guitar_two.is_vintage()))
def main(): guitar1 = Guitar("Gibson L-5 CES", 1922, 16035.4) guitar2 = Guitar("Fender Eric Clapton Stratocaster®", 1991, 3599) print(guitar1) #guitar1.get_age(age) print("get_age() - Expected 95. Got {}".format(guitar1.get_age())) print("get_age() - Expected 26. Got {}".format(guitar2.get_age())) age1 = guitar1.get_age() age2 = guitar2.get_age() print("is_vintage() - Expected True. Got {}".format( guitar1.is_vintage(age1))) print("is_vintage() - Expected False. Got {}".format( guitar2.is_vintage(age2)))
from Prac07.guitar import Guitar guitar1 = Guitar("Gibson L-5 CES", 1922, 16035.40) print(guitar1) print(guitar1.get_age()) print(guitar1.is_vintage())
from Prac07.guitar import Guitar print("My guitars!") myGuitars = [] name = input("Name: ") while name != "": year = int(input("Year: ")) cost = int(input("Cost: $")) guitar = Guitar(name, year, cost) myGuitars.append(guitar) print("{} ({}) : ${} added.".format(guitar.name, guitar.year, guitar.cost)) name = input("Name: ") myGuitars.append(Guitar("Gibson L-5 CES", 1992, 16035.40)) myGuitars.append(Guitar("Line 6 JTV", 2010, 1512.9)) for i, guitar in enumerate(myGuitars): if guitar.is_vintage(): vintage_string = "(Vintage)" else: vintage_string = "" print("Guitar {}: {:>15} ({}), worth ${:10,.2f} {}".format( i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
from Prac07.guitar import Guitar guitar = Guitar("test", 1000, 300) guitar2 = Guitar("test", 2010, 30) print("get_age() - Expected {}. Got {}.".format(2017 - guitar.year, guitar.get_age())) print("get_age() - Expected {}. Got {}.".format(2017 - guitar2.year, guitar2.get_age())) print("is_vintage() - Expected {}. Got {}.".format( True if 2017 - guitar.year >= 50 else False, guitar.is_vintage())) print("is_vintage() - Expected {}. Got {}.".format( True if 2017 - guitar2.year >= 50 else False, guitar2.is_vintage()))