public static PartTime AddPTEmployee() { PartTime AddPartTime = null; Console.WriteLine("What is your name?"); string employeeName = Console.ReadLine(); employeeName = UserValidation.IsNullOrWhiteSpace(employeeName); Console.WriteLine("What is your address?"); string employeeAddress = Console.ReadLine(); employeeAddress = UserValidation.IsNullOrWhiteSpace(employeeAddress); Console.WriteLine("What is your current pay?"); decimal employeePay = UserValidation.GetDecimal(); Console.WriteLine("How many hours per week are you working?"); decimal hoursPerWeek = UserValidation.GetDecimal(); AddPartTime = new PartTime(employeeName, employeeAddress, employeePay, hoursPerWeek); return(AddPartTime); }
static void Main(string[] args) { List <Employee> EmployeeList = new List <Employee>(); //Bool to keep the program running bool ProgramIsRunning = true; while (ProgramIsRunning) { Console.Clear(); //Menu Console.WriteLine("---------------------Menu--------------------- \n "); Console.WriteLine("1. Add Employee"); Console.WriteLine("2. Remove Employee"); Console.WriteLine("3. Display Payroll"); Console.WriteLine("4. Exit"); Console.Write("\n Please select one of the following options from the menu above: "); string userInput = Console.ReadLine(); userInput = UserValidation.IsNullOrWhiteSpace(userInput.ToLower()); //utilize swith to valid the users response. switch (userInput) { case "1": case "1.": case "add employee": { Console.Clear(); //Add employee - lets the user to choose to create an employee of type //(FullTime, PartTime, Contractor, Salaried, or Manager) prompts the user for the appropriate values, //and adds them to the list. Console.WriteLine("---------Menu--------- \n"); Console.WriteLine("1. Full Time"); Console.WriteLine("2. Part Time"); Console.WriteLine("3. Contractor"); Console.WriteLine("4. Salaried"); Console.WriteLine("5. Manager \n"); Console.Write("Please choose one of the following options to add an Employee: "); string addEmployee = Console.ReadLine(); addEmployee = UserValidation.IsNullOrWhiteSpace(addEmployee.ToLower()); if ((addEmployee == "full time" || addEmployee == "1") || (addEmployee == "1." || addEmployee == "fulltime")) { Console.Clear(); EmployeeList.Add(FullTime.AddFTEmployee()); } if ((addEmployee == "part time" || addEmployee == "2") || (addEmployee == "2." || addEmployee == "parttime")) { Console.Clear(); EmployeeList.Add(PartTime.AddPTEmployee()); } if ((addEmployee == "contractor" || addEmployee == "3") || addEmployee == "3.") { Console.Clear(); EmployeeList.Add(Contractor.AddContractorEmployee()); } if ((addEmployee == "salaried" || addEmployee == "4") || addEmployee == "4.") { Console.Clear(); EmployeeList.Add(Salaried.AddSalariedEmployee()); } if ((addEmployee == "manager" || addEmployee == "5") || addEmployee == "5.") { Console.Clear(); EmployeeList.Add(Manager.AddManager()); } else { Console.WriteLine("You did not enter a valid response. Please enter one of the menu options above."); Utility.PauseBeforeContinuing(); } } break; case "2": case "2.": case "remove employee": { Console.Clear(); DisplayList(EmployeeList); Console.WriteLine("Please select the number next to the Employees that you wish to remove:"); RemoveEmployee(EmployeeList); Utility.PauseBeforeContinuing(); } break; case "3": case "3.": case "display payroll": { Console.Clear(); DisplayPayroll(EmployeeList); Utility.PauseBeforeContinuing(); } break; case "4": case "4.": case "exit": { Console.WriteLine("You have chosen to exit you are now exiting the program."); ProgramIsRunning = false; Utility.PauseBeforeContinuing(); } break; default: { Console.WriteLine("You have not chosen a valid response."); Utility.PauseBeforeContinuing(); } break; } } }