コード例 #1
0
def main():
    movie_list = [
        Movie("Monty Python and the Holy Grail", 1975),
        Movie("On the Waterfront", 1954),
        Movie("Cat on a Hot Tin Roof", 1958)]
    # movie_list = [["Monty Python and the Holy Grail", 1975],
                #   ["On the Waterfront", 1954],
                #   ["Cat on a Hot Tin Roof", 1958]]


    display_menu()

    while True:
        command = input("Command: ")
        if command == "list":
            list(movie_list)
        elif command == "add":
            add(movie_list)
        elif command == "del":
            delete(movie_list)
        elif command == "exit":
            break
        else:
            print("Not a valid command. Please try again.\n")
    print("Bye!")
コード例 #2
0
def add(movie_list):
    name = input("Name: ")
    year = input("Year: ")
    # movie = []
    # movie.append(name)
    # movie.append(year)
    movie = Movie(name,year)
    movie_list.append(movie)
    print(movie.getStr())
コード例 #3
0
def main():
    myTimer = timer.begin_timer()
    stringer.show_welcome(NAME)
    print()
    # tuple of product objects demonstrating polymorphism
    products = (Product("Heavy hammer", 12.99,
                        62), Product("Light nails", 5.06,
                                     0), Movie("Blade Runner", 29.99, 0, 1984),
                Book("Moby Dick", 19.99, 0,
                     "Herman Melville"), Product("Medium tape", 7.24, 0))
    show_products(products)

    while True:
        print()

        try:
            number = val.get_int("Enter Product number: ", len(products), 0)
            product = products[number - 1]
            show_product(product)

        except Exception as e:
            print("There was an Error processing your product.", e)
            break

        choice = input("View another? (y/n): ").lower()
        if choice != "y":
            break

    # end while loop

    timer.stop_timer(myTimer)
    print("Bye!")
コード例 #4
0
ファイル: movies.py プロジェクト: djaramil/movies-flask
def add_movie(name,year, minutes, category_id):
    db.connect()
    category = db.get_category(category_id)
    movie = Movie(name=name, year=year, minutes=minutes,
                  category=category)
    db.add_movie(movie)
    print(name + " was added to database.\n")
コード例 #5
0
def main():
    print("The Product Viewer program")
    print()
    
    # a tuple of Product objects
    # products = (Product('Stanley 13 Ounce Wood Hammer', 12.99, 62),
    #             Book("The Big Short", 15.95, 34, "Michael Lewis","Hardcover"),
    #             Movie("The Holy Grail", 14.99, 68, 1975,"DVD"),
    #             Album("Rubber Soul", 10, 0,"The Beatles","CD"))
    products = (Product('Stanley 13 Ounce Wood Hammer', 12.99, 62),
                Book("The Big Short", 15.95, 34, "Michael Lewis","Hardcover"),
                Movie("The Holy Grail", 14.99, 68, 1975,"DVD"),
                Album("Rubber Soul", 10, 0,"The Beatles","CD"))
    show_products(products)

    while True:
        number = int(input("Enter product number: "))
        print()
    
        product = products[number-1]
        show_product(product)

        choice = input("Continue? (y/n): ")
        print()
        if choice != "y":
            print("Bye!")
            break
コード例 #6
0
def main():
    print("The Product Viewer program")
    print()
    # The main function creates a tuple of Product Objects. To do that, it calls the constructer of the Product Class
    # to create each object, and it stores each object in the tuple without going through the intermediate step of
    # creating a variable name that refers to the object type.

    products = (Product('Stanley 13 Ounce Wood Hammer', 12.99, 62),
                Book("The Big Short", 15.95, 34, "Michael Lewis"),
                Movie("The Holy Grail - DVD", 14.99, 68, 1975))
    
    show_products(products)

    # This create the a loop to keep asking for prompts.
    while True:
        # Prompts the user to enter a number that corresponds with a product
        number = int(input("Enter product number: "))
        print()
    
        # it gets the number assigned to int, substracts 1 to adjust for the index
        product = products[number-1]
        # product is assigned the object at the inputted index.
        #  the product is passed to show_product(). show_product uses if statements to handle different object attributes.
        show_product(product)

        # prompt to continue.
        choice = input("Continue?\t (y/n):\t")

        print()
        if choice != "y":
            break
コード例 #7
0
def add_movie():
    name = input("Name: ")
    year = int(input("Year: "))
    minutes = int(input("Minutes: "))
    category_id = int(input("Category ID: "))

    category = db.get_category(category_id)
    movie = Movie(name=name, year=year, minutes=minutes, category=category)
    db.add_movie(movie)
    print(name + " was added to database.\n")
コード例 #8
0
ファイル: ui.py プロジェクト: ch3gop-op/murach
def add_movie():
    name = input("Name: ")
    year = int(input("Year: "))
    minutes = int(input("Minutes: "))
    category_id = int(input("Category ID: "))

    category = db.get_category(category_id)
    if category == None:
        print("There is no category with that ID. Movie NOT added.\n")
    else:
        movie = Movie(name=name, year=year, minutes=minutes, category=category)
        db.add_movie(movie)
        print(name + " was added to database.\n")
コード例 #9
0
ファイル: override.py プロジェクト: erco1961/Python_Examples
def main():
    myTimer = timer.begin_timer()
    stringer.show_welcome(NAME)

    # create tuple of Product objects
    products = (Book("Moby Dick", 19.99, 0, "Herman Melville"),
                Product("Heavy hammer", 9.95, 13),
                Movie("Blade Runner", 29.99, 0, 1984))
    print()
    print("This program creates 3 objects of different types and, uses polymorphism to display data on each object.")
    print()
    show_products(products)
   
    timer.stop_timer(myTimer)
    print("Bye!")
コード例 #10
0
ファイル: movie_list_gui.py プロジェクト: smyhk/movie-catalog
    def saveMovie(self):
        movieTitle = self.movieTitle.get()
        year = int(self.year.get())
        category = self.category.get()
        minutes = int(self.minutes.get())

        category = db.get_category_by_name(category)

        movie = Movie(name=movieTitle,
                      year=year,
                      minutes=minutes,
                      category=category)
        db.add_movie(movie)

        self.confirmMovieAdd(movieTitle)

        mof = MovieOutputFrame(self)
        mof.refresh_record_view()
コード例 #11
0
def main():
    print("The Product Viewer program")
    print()

    products = (Product("Stanley 13 Ounce wood Hammer", 12.99, 62),
                Product('National Hardware 3/4" Wire Nails', 5.06,
                        5), Book("The Big Short", 15.95, 34, "Michael Lewis"),
                Movie("The Holy Grail - DVD", 14.99, 68, 1975))
    show_products(products)

    while True:
        number = int(input("Enter product number: "))
        print()

        product = products[number - 1]
        show_product(product)

        choice = input("Continue? (y/n): ").lower()
        print()
        if choice != "y":
            break
コード例 #12
0
def main():
    print("The Product Viewer program")
    print()
    
    # a tuple of Product objects
    products = (Product('Stanley 13 Ounce Wood Hammer', 12.99, 62),
                Book("The Big Short", 15.95, 34, "Michael Lewis"),
                Movie("The Holy Grail - DVD", 14.99, 68, 1975))
    show_products(products)

    while True:
        number = int(input("Enter product number: "))
        print()
    
        product = products[number-1]
        show_product(product)

        choice = input("Continue? (y/n): ")
        print()
        if choice != "y":
            print("Bye!")
            break
コード例 #13
0
def main():
    print("The Product Viewer program")
    print()

    # a tuple of Product objects
    products = (Product('Stanley 13 Ounce Wood Hammer', 12.99, 62),
                Book("The Big Short", 15.95, 34, "Hardcover", "Michael Lewis"),
                Movie("The Holy Grail", 14.99, 68, "DVD", 1975),
                Album("A Matter of Life And Death", 19.99, 15, "CD",
                      "Iron Maiden"))
    show_products(products)

    while True:
        number = int(input("Enter product number: "))
        print()

        product = products[number - 1]
        show_product(product)

        choice = input("Continue? (y/n): ")
        print()
        if choice != "y":
            print("Bye!")
            break
コード例 #14
0
def make_movie(row):
    return Movie(row["movieID"], row["name"], row["year"], row["minutes"],
                 make_category(row))
コード例 #15
0
ファイル: movies.py プロジェクト: DSHaworth/MurachPython
def add(movie_list):
    name = input("Name: ")
    year = input("Year: ")
    movie_list.append(Movie(name, year))
    print(name + " was added.\n")