Exemplo n.º 1
0
def list_categories():
    print_header("List of categories used on the system")
    already_printed = []
    for item in catalog:
        if not item.category in already_printed:
            print(item.category)
            already_printed.append(item.category)           
Exemplo n.º 2
0
def categories():
    print_header(" Categories In Warehouse")
    already_printed = []
    for item in catalog:
        if item.id > 0 and not item.category in already_printed:
            print(item.category)
            already_printed.append(item.category)
Exemplo n.º 3
0
def print_stock_value():
    print_header(" Current Stock Value")
    total = 0.0
    for item in catalog:
        total += (item.price * item.stock)

    print("Total value: " + str(total))
Exemplo n.º 4
0
def display_no_stock():
    print_header(' Items left in stock ')
    print('|ID  |   Title              | Category        |     Price | Stock ')
    print('-' * 80)

    for item in catalog:
        print("|" + str(item.id).ljust(3) + " | " + item.title.ljust(20) +
              " | " + item.category.ljust(15) + " | " +
              str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))
Exemplo n.º 5
0
def display_catalog():
    print_header(' Catalog ')
    print(
        '  Title              |   Category         | Price     | Stock       ')
    for item in catalog:
        print(
            item.title.ljust(20) + " | " + item.category.ljust(18) + " | " +
            str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 6
0
def display_zero_stock():
    print_header(' Catalog ')
    print(
        '|ID |Title                | Category           | Price     | Stock       '
    )
    for item in catalog:
        if (item.stock == 0):
            print("|" + str(item.id).ljust(3) + "|" + item.title.ljust(20) +
                  " | " + item.category.ljust(18) + " | " +
                  str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 7
0
def display_removed():
    print_header('  Removed items')
    print(' |   Title              | Category        |     Price | Stock ')
    print('-' * 80)

    for item in catalog:
        if (item.id == 0):
            print(" | " + item.title.ljust(20) + " | " +
                  item.category.ljust(15) + " | " + str(item.price).rjust(9) +
                  " | " + str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 8
0
def display_catalog():
    num_items = len(catalog)
    print_header(' Your catalog contains ' + str(num_items) + ' Items ')
    print(' |ID   |  Title                 | Category           |      Price  | Stock     ]')
    print('-' * 80)
   
    for item in catalog:
        print(item.title.ljust(20) 
        + " | " + item.category.ljust(15) 
        + " | " + str(item.price).rjust(9) 
        + " | " + str(item.stock).rjust(5) )
   
    print('-' * 80)
Exemplo n.º 9
0
def display_no_stock():
    print_header(' This is your Catalog ')    
    print('  Title              | Category        |     Price | Stock ')
    print('-' * 80)


    for item in catalog:
        if(item.stock == 0):
            print(item.title.ljust(20) 
                + " | " + item.category.ljust(15) 
                + " | " + str(item.price).rjust(9) 
                + " | " + str(item.stock).rjust(5))
    print('-' * 80)
Exemplo n.º 10
0
def display_catalog():
    num_items = len(catalog)  # <- length of array or string
    print_header(' This is your Catalog ')
    print('|ID  |   Title              | Category        |     Price | Stock ')

    print('-' * 80)

    for item in catalog:
        print("|" + str(item.id).ljust(3) + " | " + item.title.ljust(20) +
              " | " + item.category.ljust(15) + " | " +
              str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 11
0
def display_no_stock():
    print_header(' Your Catalog contains ' + str(num_items) + ' Items')
    print(' Title | Category | Price | Stock ')
    print('-' * 80)

    for item in catalog:
        if (item.stock == 0):
            print(
                item.title.ljust(20) + " | " + item.category.ljust(15) +
                " | " + str(item.price).rjust(9) + " | " +
                str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 12
0
def display_catalog():
    num_items = len(catalog)  # <- get length of array or string

    print_header('Your Catalog contains ' + str(num_items) + ' Items ')
    print('|ID  |   Title              | Category        |     Price | Stock ')
    print('-' * 80)

    for item in catalog:
        if (item.id > 0):
            print("|" + str(item.id).ljust(3) + " | " + item.title.ljust(20) +
                  " | " + item.category.ljust(15) + " | " +
                  str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))

    print('-' * 80)
Exemplo n.º 13
0
def register_item():
    global id_count
    print_header(' Register new Item ')
    title = input('Please input Title: ')
    category = input('Please input Category: ')
    price = float(input('Please input Price: '))
    stock = int(input('Please input Stock: '))

    new_item = Item()
    new_item.id = id_count
    new_item.title = title
    new_item.category = category
    new_item.price = price
    new_item.stock = stock

    id_count += 1
    catalog.append(new_item)
    print(" Item created!")
Exemplo n.º 14
0
def register_item():
    print_header('  Register NEw Item')
    title = input('Enter a Title: ')
    category = input('Enter a Category: ')
    price = float(input('Enter a Price: '))
    stock = int(input('Enter Inventory Amount: '))

    # validations

    # create object below
    new_item = Item()
    new_item.title = title
    new_item.category = category
    new_item.price = price
    new_item.stock = stock
    print(new_item.title)

    catalog.append(new_item)
    print("Item Created!")
Exemplo n.º 15
0
def register_item():
    global id_count  #import the global variable into fn scope
    print_header('Register new Item')
    title = input('Please input Title:')
    category = input('Please input Category:')
    price = float(input('please input Price:'))
    stock = int(input('Please input Stock: '))
    # do validations here

    # create the object
    new_item = Item()  # <--how to create an object of a class
    new_item.id = id_count
    new_item.title = title
    new_item.category = category
    new_item.price = price
    new_item.stock = stock

    id_count += 1
    catalog.append(new_item)
    print(" Item created!")
Exemplo n.º 16
0
def display_selected_category():
    print_header(' Catalog ')
    print(' | Categories          |')
    unique_catagories = set()
    for item in catalog:
        unique_catagories.add(item.category)
    print(" | " + str(list(unique_catagories)) + "          |")

    selected = input(' Please select the Category to display items: ')
    print('')
    found = False
    print(
        '|ID |Title                | Category           | Price     | Stock       '
    )
    for item in catalog:
        if (item.category.upper() == selected.upper()):
            print("|" + str(item.id).ljust(3) + "|" + item.title.ljust(20) +
                  " | " + item.category.ljust(18) + " | " +
                  str(item.price).rjust(9) + " | " + str(item.stock).rjust(5))
            found = True
    print('-' * 80)

    if (found == False):
        print('** Error : Selected Category does not exist.')