Exemplo n.º 1
0
def main():
    # Create three instances of RetailItem.
    item1 = retail.RetailItem('Jacket', 12, 59.95)
    item2 = retail.RetailItem('Designer Jeans', 40, 34.95)
    item3 = retail.RetailItem('Shirt', 20, 24.95)

    # Display information.
    print('Retail Item 1: ')
    print(item1)
    print()
    print('Retail Item 2:')
    print(item2)
    print()
    print('Retail Item 3:')
    print(item3)
Exemplo n.º 2
0
def main():

    # Create sale items.
    pants = retail.RetailItem('Pants', 10, 19.99)
    shirt = retail.RetailItem('Shirt', 15, 12.50)
    dress = retail.RetailItem('Dress', 3, 79.00)
    socks = retail.RetailItem('Socks', 50, 1.00)
    sweater = retail.RetailItem('Sweater', 5, 49.99)

    # Create dictionary of sale items.
    sale_items = {
        PANTS: pants,
        SHIRT: shirt,
        DRESS: dress,
        SOCKS: socks,
        SWEATER: sweater
    }

    # Create a cash register.
    register = cashRegister.CashRegister()

    # Initialize loop test.
    checkout = 'N'

    # User wants to purchase more items:
    while checkout == 'N':

        user_choice = get_user_choice()
        item = sale_items[user_choice]
        if item.get_inventory() == 0:
            print('The item is out of stock.')
        else:
            register.purchase_item(item)

            # update item
            new_item = retail.RetailItem(item.get_description(), \
                                         item.get_inventory()-1, \
                                         item.get_price())
            sale_items[user_choice] = new_item

            checkout = input('Are you ready to check out (Y/N)? ')

    print()
    print('Your purchase total is: ', \
          format(register.get_total(), '.2f'))
    print()
    register.show_items()
    register.clear()
Exemplo n.º 3
0
def main():
    #create sale items
    Item1 = retail.RetailItem("Item1", 10,
                              (19.99 - (19.99 * .1)))  #10 percent discount
    Item2 = retail.RetailItem("Item2", 15, 12.50)  # not discount
    Item3 = retail.RetailItem("Item3", 3,
                              79.00 - (79.00 * 0.15))  #15% discount
    Item4 = retail.RetailItem("Item4", 50, 1.00)  #not discount
    Item5 = retail.RetailItem("Item5", 5,
                              49.99 - (49.99 * 0.1))  #10% disccount

    # create dictionary of sale items
    sale_items = {
        ITEM1: Item1,
        ITEM2: Item2,
        ITEM3: Item3,
        ITEM4: Item4,
        ITEM5: Item5
    }

    # create a cash register
    register = cash_register.CashRegister()

    # initialize loop test
    checkout = 'N'

    # user wants to purchase more items
    while checkout == 'N':
        user_choice = get_user_choice()
        item = sale_items[user_choice]
        if item.get_inventory() == 0:
            print("The item is out of stock.")
        else:
            register.purchase_item(item)
            # update item
            new_item = retail.RetailItem(item.get_description(), item.get_inventory()-1,\
                                         item.get_price())

            sale_items[user_choice] = new_item
            checkout = input("Are you ready to check out (Y/N)? ")
    print()
    print("Your purchase total is: ", format(register.get_total(), '.2f'))
    print()
    register.show_items()
    register.clear()
Exemplo n.º 4
0
def main():

    #create sale items
    pants = retail.RetailItem("Pants", 10, 19.99)
    shirt = retail.RetailItem("Shirt", 15, 12.50)
    dress = retail.RetailItem("Dress", 3, 79.00)
    socks = retail.RetailItem("Socks", 50, 1.00)
    sweater = retail.RetailItem("Sweater", 5, 49.99)

    # create dictionary of sale items
    sale_items = {PANTS:pants, SHIRT:shirt, \
                  DRESS:dress, SOCKS:socks, SWEATER:sweater}

    # create a cash register
    register = cashRegister.CashRegister()

    # initialize loop test
    checkout = 'N'

    # user wants to purchase more items
    while checkout == 'N':

        user_choice = get_user_choice()
        item = sale_items[user_choice]
        if item.get_inventory() == 0:
            print("The item is out of stock.")
        else:
            register.purchase_item(item)

            # update item
            new_item = retail.RetailItem(item.get_description(),\
                                         item.get_inventory()-1,\
                                         item.get_price())
            sale_items[user_choice] = new_item

            checkout = input("Are you ready to check out (Y/N)? ")

    print()
    print("Your purchase total is: ", format(register.get_total(), '.2f'))
    print()
    register.show_items()
    register.clear()