Beispiel #1
0
def main():

    # while True:
    #     name = input("enter a name")
    #     if name == '':
    #         break
    #     else:
    #         year = int(input("enter what year it was made"))
    #         cost = int(input("enter the cost"))
    # guitars.append(Guitar(name,year,cost))

    Gibson = Guitar("Gibson L-5 CES", 1922, 16035.40)
    Line = Guitar("Line 6 JTV-59", 2010, 1512.9)
    guitars = [Gibson, Line]

    counter = 0
    for i, guitar in enumerate(guitars):
        vintage_string = ""
        if guitar.is_vintage():
            vintage_string = "(Vintage)"
        # print("Guitar", counter + 1, ":", guitars[counter])
        # counter += 1
        print("Guitar {}: {:>20} ({}), worth ${:10,.2f} {}".format(
            i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
        i += 1
Beispiel #2
0
def main():
    guitars = []

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

        name = input("Name: ")

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

    print("These are my guitars")

    longest_name = max(len(guitar.name) for guitar in guitars)
    longest_cost = max(len("{:.2f}".format(guitar.cost)) for guitar in guitars)

    for index, guitar in enumerate(guitars):
        vintage_status = "(vintage)" if guitar.is_vintage() else ""

        print("Guitar {0}: {self.name:>{1}} ({self.year}), worth "
              "${self.cost:<{2},.2f} {3}".format(index + 1, longest_name, longest_cost, vintage_status, self=guitar))
Beispiel #3
0
def main():
    # my_guitars = GuitarList()
    # run = True
    # while run:
    #     name = input("name:")
    #     if name == "":
    #         break
    #     year = input("year:")
    #     cost = input("cost:")
    #     my_guitars.add(Guitar(name, int(year), float(cost)))
    #     print("{} ({}): ${:.2f} added.".format(name, int(year), float(cost)))
    #     print(my_guitars)
    # print("These are my Guitars:")

    guitars = []
    name = input("name:")
    while name != "":
        year = input("year:")
        cost = input("cost:")
        guitars.append(Guitar(name, int(year), float(cost)))
        name = input("name:")
    # guitars.append(Guitar("Gibson L-5 CES", 1922, 16035.40))
    # guitars.append(Guitar("Line 6 JTV-59", 2010, 1512.9))
    # guitars.append(Guitar("Fender Stratocaster", 1964, 18480.65))
    for i, guitar in enumerate(guitars):
        if guitar.is_vintage():
            vintage_string = "(Vintage!)"
        else:
            vintage_string = ""
        print("Guitar {}: {:>20} ({}), worth ${:10,.2f} {}".format(
            i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
Beispiel #4
0
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)))
Beispiel #5
0
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()))
Beispiel #6
0
def main():
    guitars = [
        Guitar("Gibson L-5 CES", 1922, 16035.40),
        Guitar("Line 6 JTV-59", 2010, 1512.9)
    ]
    print("My Guitars!")
    name = input("Name: ")
    while name != "":
        year = int(input("Year: "))
        cost = float(input("Cost: $"))
        guitars.append(Guitar(name, year, cost))
        name = input("Name: ")
    print("These are my guitars:")
    for i, guitar in enumerate(guitars):
        if guitar.is_vintage():
            vintage_string = "(vintage)"
        else:
            vintage_string = ""
        print("Guitar {}: {:>20} ({}), worth ${:10,.2f} {}".format(
            i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
Beispiel #7
0
def main():
    print("My guitars!")

    guitars = []

    name = input("Name: ")
    while name != "":
        year = int(input("Year: "))
        cost = float(input("Cost: $"))
        guitars.append(Guitar(name, year, cost))
        name = input("Name: ")
    display_guitars(guitars)
Beispiel #8
0
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))
Beispiel #9
0
def main():
    guitar_list = []
    name = input("Name: ")
    while name != "":
        year = int(input("Year: "))
        cost = float(input("Cost: $"))
        print(Guitar(name, year, cost), "added.")
        guitar_list.append(Guitar(name, year, cost))
        name = input("Name: ")

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

    print("These are my guitars:")
    count = 0
    for guitar in guitar_list:
        guitar.is_vintage()
        count += 1
        print("Guitar {}: {:>20} "
              "({}), worth $"
              "{:10.2f} {}".format(count, guitar.name, guitar.year,
                                   guitar.cost, guitar.vintage))
def main():
    guitars = []
    in_file = open("guitars.csv", "r")
    for line in in_file:
        parts = line.strip().split(",")
        guitar = (parts[0], parts[1], parts[2])
        guitars.append(guitar)
    in_file.close()
    for guitar in guitars:
        print(guitar)
    guitar_objects = []
    in_file = open("guitars.csv", "r")
    for line in in_file:
        parts = line.strip().split(",")
        guitar_object = Guitar(parts[0], int(parts[1]), float(parts[2]))
        guitar_objects.append(guitar_object)
    for guitar_object in guitar_objects:
        print(guitar_object)
    in_file.close()
    print("Sorted by year")
    guitar_objects.sort()
    for guitar_object in guitar_objects:
        print(guitar_object)
    print("Adding New Guitars")
    name = input("Guitar name: ")
    while name != "":
        year = int(input("Year made: "))
        cost = float(input("Cost: "))
        guitar_objects.append(Guitar(name, year, cost))
        name = input("Guitar name: ")
    out_file = open("guitars.csv", "w")
    for guitar_object in guitar_objects:
        out_file.write("{},{},{}\n".format(guitar_object.name,
                                           guitar_object.year,
                                           guitar_object.cost))
    out_file.close()
def main():
    guitars = []
    name = input("Guitar name: ")
    while name != "":
        year = int(input("Year made: "))
        cost = float(input("Cost: "))
        guitars.append(Guitar(name, year, cost))
        name = input("Guitar name: ")
    print("These are my guitars:")
    for i, guitar in enumerate(guitars):
        if guitar.is_vintage():
            vintage_string = "(vintage)"
        else:
            vintage_string = ""
        print("Guitar {}: {:>20} ({}), worth ${:10,.2f} {}".format(
            i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
Beispiel #12
0
def main():
    print("My guitars!")
    guitars = []
    name = input("Name: ")
    while name.strip() == "":
        year = int(input("Year: "))
        cost = int(input("Cost: $"))
        guitars.append(Guitar(name, year, cost))
        name = input("Name: ")

    # gibson = Guitar("Gibson L-5 CES", 1922, 16035.40)
    # test_guitar_one = Guitar("Name", 1950, 2004.23)
    # test_guitar_two = Guitar("TestName", 2004, 200.3003)

    for i, guitar in enumerate(guitars):
        if guitar.is_vintage():
            vintage_string = "(vintage)"
        else:
            vintage_string = ""

        print("Guitar {}: {:>20} ({}), worth ${:10,.2f} {}".format(
            i + 1, guitar.name, guitar.year, guitar.cost, vintage_string))
Beispiel #13
0
from Prac07.guitar import Guitar

guitar1 = Guitar("Gibson L-5 CES", 1922, 16035.40)

print(guitar1)

print(guitar1.get_age())
print(guitar1.is_vintage())
Beispiel #14
0
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()))
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))
Beispiel #16
0
from Prac07.guitar import Guitar

guitar1 = Guitar()
guitar1.name = "Gibson L-5 CES"
guitar1.year = 1922
guitar1.cost = 16035.40

guitar2 = Guitar()
guitar2.name = "Ashton"
guitar2.year = 2012
guitar2.cost = 100.00

# print(guitar1)
# print(guitar1.get_age())
# print(guitar1.is_vintage())
#
# print(guitar2)
# print(guitar2.get_age())
# print(guitar2.is_vintage())

print(guitar1)
print(guitar2)
Beispiel #17
0
from Prac07.guitar import Guitar

print("My guitars!")
guitar_list = []
while True:
    name = str(input("Name: "))
    if name == "":
        print("       ...snip...")
        break
    year = int(input("Year: "))
    cost = float(input("Cost: $"))
    guitar = Guitar(name, year, cost)
    guitar_list.append(guitar)
    print("{} ({}) : ${:.2f} added.".format(name, year, cost))

counter = 1
for guitar in guitar_list:
    print("Guitar {}: {}".format(counter, guitar))
    counter += 1

#  it's probably wrong but i'm super tired and my head hurts when i try to think, sorry - i tried