import sys from Customer import * from Customers import * from Part import * from Parts import * from Order import * from Orders import * # Open three files, customers.dat, parts.dat, and orders.dat, # present in directory dname. # Read the data and construct the customers, parts, and orders objects # Return the three objects as a tuple (see main() for the order) def load_data(dname): # load customers data pass # load parts data pass # load the orders data # ATL-1000:1111:12-10-2022:1000,5,20:1001,20,10:1004,15,15 pass return customers, parts, orders # Store data from customers, parts, and orders objects into three files, # customers.dat, parts.dat, and orders.dat in the folder named dname; # Use same format as when you loaded the data def store_data(customers,parts,orders,dname): pass def main(): customers,parts,orders = load_data(sys.argv[1]) #print(customers) #print(parts) #print(orders) print("\nWelcome to Orders Database Program\n") while True: command = input("c, c cno, o ono, u ono pno discount, d ono pno, q: ").strip() if len(command) < 1: print("\nInvalid command!\n") continue elif command[0] == 'c' and len(command) == 1: print() print(customers) elif command[0] == 'c' and len(command) > 1: cno = int(command[1:].strip()) c = customers.get_customer(cno) if c == None: print("\nInvalid Customer Number",cno,"\n") continue else: print() print(c) onos = orders.get_orders_for_customer(cno) print("ORDERS: ",end="") for ono in onos: print(ono," ",end="") print("\n") elif command[0] == 'o': ono = command[2:].strip().upper() o = orders.get_order(ono) if o != None: print() print(o) else: print("\n"+ono+" NOT FOUND\n") elif command[0] == 'u': ono, pno, discount = command[2:].split() pno = int(pno) discount = int(discount) o = orders.get_order(ono) if o != None: print() if o.update_discount(pno,discount): print("Discount updated!\n") else: print("No such part in order!\n") else: print("\n"+ono+" NOT FOUND\n") elif command[0] == 'd': ono, pno = command[2:].split() pno = int(pno) o = orders.get_order(ono) if o != None: print() if o.delete_part(pno): print("Part deleted from order!\n") if o.empty_order(): if orders.delete_order(ono): print("Empty order deleted!") else: print("Something went wrong!") else: print("No such part in order!\n") else: print("\n"+ono+" NOT FOUND\n") elif command[0] == 'q': break else: print("\nInvalid command\n") store_data(customers,parts,orders,sys.argv[1]) print("\nBye!\n") main()