objPI = Emp(1, "Andrew", "Jackson") objP2 = Emp(2, "James", "Buchanan") list_of_objects = [objPI, objP2] for row in list_of_objects: print(row.to_string(), type(row)) # Show user a menu of options # Get user's menu option choice while True: Eio.print_menu_options() strChoice = Eio.input_menu_options() # Show user current data in the list of employee objects if strChoice == "1": Eio.print_current_list_employees(list_of_objects) Eio.input_press_to_continue() continue # Let user add data to the list of employee objects elif strChoice == "2": print(Eio.input_employee_data(list_of_objects)) Eio.input_press_to_continue() continue # let user save current data to file elif strChoice == "3": P.FileProcessor.save_data_to_file("EmployeeData.txt", list_of_objects) Eio.input_press_to_continue() continue # let user read current data from file
strChoice = Eio.input_menu_options() if strChoice.strip() == "1": # Show user current data in the list of employee objects # for row in lstTable: Eio.print_current_list_items(lstTable) elif strChoice.strip() == "2": # Let user add data to the list of employee objects new_employee = Eio.input_employee_data() print(new_employee.to_string().strip()) # Debuggins statement lstTable, strStatus = P.DatabaseProcessor.add_data_to_list( new_employee, lstTable) Eio.input_press_to_continue(strStatus) elif strChoice.strip() == "3": # let user save current data to file P.FileProcessor.save_data_to_file(file_name, lstTable) elif strChoice.strip() == "4": # Let user exit program print("Goodbye") break else: print("Choice Must be 1, 2, 3, or 4") except Exception as e: print("There was a non-specific error!")
strChoice = "" # Captures the user option selection # Main Body of Script ---------------------------------------------------- # # Load data from file into a list of employee objects when script starts try: # Use this Processor function to read a text file and return a table of data lstTable = Fp.read_data_from_file(strFileName) # read file data Eio.print_intro() # print the script intro here while True: Eio.print_menu_items() # print the menu here strChoice = Eio.input_menu_options() # Get menu option # Process user's menu choice if strChoice.strip() == '1': # Print the Employee Information Eio.print_current_list_items( lstTable) # <<Print the list of employees here Eio.input_press_to_continue() # send a message to the user elif strChoice == '2': # Enter New Employee ID's and names while True: # Use a While loop to allow for continued data entry # Use this Eio function to input a new Employee Id and Name Info strNewEmp = Eio.input_employee_data( lstTable) # Input New Employee Info here strEmpInfo = str( strNewEmp ) # Took the returned Employee info and set to this string variable here empID, empFirstName, empLastName = strEmpInfo.split( ",") # Split out the various string pieces here # Print show the data for the new employee that was added print("New Employee Added: " + "ID: " + empID + " - " + empFirstName + " " + empLastName) # Evaluate the user choice and exit loop if "n" in response if "n" in Eio.input_yes_no_choice():