-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
62 lines (47 loc) · 1.24 KB
/
app.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from product import Product
product_list = []
def createProduct():
id = input("id: ")
name = input("name: ")
price = input("price: ")
product = Product(id, name, price)
product_list.append(product)
def readProduct():
for i in product_list:
print(i.id, i.name, i.price)
def updateProduct():
id = input("Choice id to Update: ")
product = None
for i in product_list:
if i.id == id:
product = i
break
if product is None:
print("Product not find.")
return
new_name = input("Update product name: ")
new_price = input("Update product price: ")
product.name = new_name
product.price = new_price
print("Product succesfull updated.")
def deleteProduct():
id = input("Choice id to delete: ")
for i in product_list:
if i.id == id:
product_list.remove(i)
while True:
print("Menu")
print("1. Create")
print("2. Read")
print("3. Update")
print("4. Delete")
user_input = input("Choice: ")
match user_input:
case "1":
createProduct()
case "2":
readProduct()
case "3":
updateProduct()
case "4":
deleteProduct()