forked from mlosa001/Inventory-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
31 lines (29 loc) · 1.38 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from inventory import Inventory
if __name__ == '__main__':
username = input("Hello welcome to Productland! What is your name? ")
inventory = Inventory()
cont = True
while cont:
cmd = input('\nHello, ' + username + '\nHow may I help you?\n[C]reate new product\n[R]ead your product list / See Sum\n[U]pdate a product\n[D]elete a product\n[Q]uit\n>>>')
if cmd.lower() not in ['c', 'r', 'u', 'd','q']:
print('!! Unknown command {} !!'.format(cmd))
else:
if cmd.lower() == 'q':
cont = False
elif cmd.lower() == 'd':
pid = input("Please enter product id you want to delete: ")
inventory.delete_product(pid)
elif cmd.lower() == 'c':
print("Please enter new product information")
name = input("Name: ")
price = input("Price: ")
quantity = input("Quantity: ")
_id = inventory.get_last_id()
inventory.set_product(name, price, _id, quantity)
print("New product is added to inventory with id: {}".format(_id))
elif cmd.lower() == 'r':
inventory.list_products()
elif cmd.lower() == 'u':
pid = input("Please enter product id you want to update: ")
inventory.update_product(pid)
print("\n")