public void AddEmployee() { do { if (Lawyer.GetYesNo("Do you want to see all existing employees?")) { ReadEmployees(); } string firstname = Lawyer.GetResponse("What is the first name of this employee?"); string lastname = Lawyer.GetResponse("What is the last name of this employee?"); while (Reader.DoesEmployeeExist(firstname, lastname)) { Console.WriteLine("Sorry but that employee already exists, try again"); firstname = Lawyer.GetResponse("What is the first name of this employee?"); lastname = Lawyer.GetResponse("What is the last name of this employee?"); } int vacations = Lawyer.GetInt("How many vacation days does this employee have for the year?"); if (Lawyer.GetYesNo("Are you sure you want to add " + firstname + " " + lastname + " to the employees")) { Creator.AddEmployee(firstname, lastname, vacations); NumberOfEmployees++; Console.Clear(); } Console.Clear(); } while (Lawyer.GetYesNo("Do you want to add another employee?")); }
/// <summary> /// gets an employee to use for scheduling purposes /// </summary> /// <param name="lawyer">takes in a lawyer object to be used</param> /// <returns>an employee through multiple questions</returns> private static Employee GetEmployee(Lawyer lawyer) { if (lawyer.GetYesNo("Do you know the last name of the employee?")) { string lastname = lawyer.GetResponse("What is the last name of the employee?"); while (!(Reader.DoesEmployeeExist(lastname))) { lastname = lawyer.GetResponse("Sorry no employee under that last name exist.\nWhat is the name of the employee?"); } foreach (var employee in Reader.Employees) { if (employee.LastName == lastname && Reader.GetNumberOfEmployeeWSameName(lastname) == 1) { return(employee); } else if (employee.LastName == lastname) { string firstletter = lawyer.GetResponse("Sorry there are two or more employees with that last name.\nWhat is the first letter of the employees name"); if (employee.FirstName[0].ToString() == firstletter) { return(employee); } else { Console.WriteLine("Guess you are looking for the other"); continue; } } } } foreach (var employee in Reader.Employees) { Console.Write("First Name: " + employee.FirstName + " \nLast Name: " + employee.LastName + " "); if ((lawyer.GetYesNo("Is this the employee you want to use?"))) { return(employee); } Console.Clear(); } Employee bob = new Employee("Bob", "Bob", 10000); return(bob); }