Ejemplo n.º 1
0
def main():
    guitars = []

    name = input("Name:")
    while name != "":
        year = int(input("Year:"))
        cost = int(input("Cost"))
        guitar_to_add = Guitar(name, year, cost)
        guitars.append(guitar_to_add)
        print(guitar_to_add, )
        name = input("Name:")

    guitars.append(Guitar("Gibson L-5 CES", 1922, 16035.40))
    guitars.append(Guitar("Line 6 JTV-59", 2010, 1512.9))

    if guitars:
        guitars.sort()
        print("These are my guitars:")
        for i, guitar in enumerate(guitars):
            vintage_string = ""
            if guitar.is_vintage():
                vintage_string = "(vintage)"
            print("Guitar {0}: {1.name:>30} ({1.year}), worth ${1.cost:10,.2f} {2}".format(i + 1, guitar, vintage_string))
    else:
        print("No guitars :( Quick, go and buy one!")
Ejemplo n.º 2
0
def main():
    guitars = []

    print("My Guitars")
    # name = input("Name: ")
    # while name != "":
    #     year = int(input("Year: "))
    #     cost = float(input("Cost: $"))
    #     add_guitar = Guitar(name, year, cost)
    #     guitars.append(add_guitar)
    #     print("{} added".format(add_guitar))
    #     name = input("Name: ")

    guitars.append(Guitar("Gibson L-5 CES", 1922, 16035.40))
    guitars.append(Guitar("Line 6 JTV-59", 2010, 1512.9))
    print(guitars)
    print("These are my guitars:")

    if guitars is not None:
        for i, guitar in enumerate(guitars):
            vintage_string = ""
            if guitar.is_vintage():
                vintage_string = "(vintage)"
            print("Guitar {}: {} ({}), worth ${}{}".format(
                i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
    else:
        print("No guitars :( Quick, go and buy one!")
Ejemplo n.º 3
0
def main():
    name = "Gibson L-5 CES"
    year = 1922
    cost = 16035.40

    guitar = Guitar(name, year, cost)
    print(guitar)
Ejemplo n.º 4
0
def main():
 name = "Gibson L-5 CES"
 year = 1922
 cost = 16035.40

 guitar = Guitar(name, year, cost)
 other = Guitar("Another Guitar", 2012, 1512.9)

 print("{} get_age() - Expected(). Got {}".format(guitar, name, 95, guitar.get_age()))
 print("{} get_age() - Expected(). Got {}".format(other, name, 5, other.get_age()))
 print()
 print("{} is_vintage() - Expected {}. Got {}". format(guitar.name,True, guitar.is_vintage()))
 print("{} is_vintage() - Expected {}. Got {}". format(other.name,False, other.is_vintage()))
 print()
Ejemplo n.º 5
0
def run_tests():
    """Tests for Guitar class."""
    name = "Gibson L-5 CES"
    year = 1922
    cost = 16035.40

    guitar = Guitar(name, year, cost)
    other = Guitar("Another Guitar", 2012, 1512.9)

    print("{} get_age() - Expected {}. Got {}".format(guitar.name,
                                                      CURRENT_YEAR - year,
                                                      guitar.get_age()))
    print("{} get_age() - Expected {}. Got {}".format(other.name,
                                                      CURRENT_YEAR - year,
                                                      other.get_age()))
    print()
    print("{} is_vintage() - Expected {}. Got {}".format(
        guitar.name, True, guitar.is_vintage()))
    print("{} is_vintage() - Expected {}. Got {}".format(
        other.name, False, other.is_vintage()))
Ejemplo n.º 6
0
from Prac_6.guitar import Guitar

guitar = Guitar("Gibson L-5 CES", 1922, 16035.40)
other_guitar = Guitar("Another Guitar", 2012, 1500)

print("{} get_age() - Expected 96. Got {}".format(guitar.name,
                                                  guitar.get_age()))

print("{} get_age() - Expected 6. Got {}".format(other_guitar.name,
                                                 other_guitar.get_age()))

print()
print("{} is_vintage() - Expected True. Got {}".format(guitar.name,
                                                       guitar.is_vintage()))
print("{} is_vintage() - Expected False. Got {}".format(
    other_guitar.name, other_guitar.is_vintage()))