import ProcessingClasses as P # processing classes from IOClasses import EmployeeIO as IO # Input/Output classes else: raise Exception("This file was not created to be imported") # Test data module objP1 = Emp(1, "Bob", "Smith") objP2 = Emp(2, "Lue", "Jones") lstTable = [objP1, objP2] for row in lstTable: print(row.to_string(), type(row)) # Test processing module P.FileProcessor.save_data_to_file("EmployeeData.txt", lstTable) lstFileData = P.FileProcessor.read_data_from_file("EmployeeData.txt") lstTable.clear() for line in lstFileData: lstTable.append(Emp(line[0], line[1], line[2].strip())) # for row in lstTable: # print(row.to_string(), type(row)) # Test IO module IO.show_menu() print("_______________") IO.show_current_employees(lstTable) print(IO.input_new_employee()) print(IO.input_menu_choice())
for line in list_table: list_of_objects.append(Emp(line[0], line[1], line[2].strip())) # While loop to display Menu with options while True: # Show user a menu of options IO.show_menu() # Get user's menu option choice strChoice = IO.input_menu_choice() if strChoice.strip() == '1': # Show user current data in the list of employee objects IO.show_current_employees(list_of_objects) continue elif strChoice.strip() == '2': # Let user add new employee try: emp = IO.input_new_employee() list_of_objects.append(emp) except ValueError as e: print(e) continue elif strChoice.strip() == '3': # let user save current data to file FP.FileProcessor.save_data_to_file(file_name, list_of_objects) continue elif strChoice.strip() == '4': # Let user exit the program print("Goodbye!") break # except Exception as e: print("There was an error!")