static void Main(string[] args) { Person person = new Person(); PropertyInfo[] personProperties = typeof(Person).GetProperties(); personProperties[0].SetValue(person, "Blake"); personProperties[1].SetValue(person, "Edwards"); personProperties[2].SetValue(person, (uint)15); ourPeeps.Add(person); Console.Write("***********************************************************\n" + "* Dev.Build(2.0) - My Peeps *\n" + "***********************************************************\n\n"); while (true) { MenuHandling.PrintMenuOptions(mainMenuOptions, menuMode: true); var userSelection = UserInput.SelectMenuOption(mainMenuOptions.Length); switch (mainMenuOptions[userSelection - 1]) { case "Display List of Persons": { MenuHandling.PrintMenuOptions(ourPeeps.ToArray(), messagePrompt: "First Name".PadRight(15) + "Last Name".PadRight(15) + "Age".PadRight(6) + "Email Address".PadRight(20) + "\n" + "==========".PadRight(15) + "=========".PadRight(15) + "===".PadRight(6) + "======================".PadRight(20)); break; } case "Add Person": AddPerson(ourPeeps); break; case "Delete Person": DeletePerson(ourPeeps); break; case "Exit": return; } } }
static void Main(string[] args) { Console.Write("***********************************************************\n" + "* Dev.Build(2.0) - My Peeps *\n" + "***********************************************************\n\n"); while (true) { MenuHandling.PrintMenuOptions(mainMenuOptions, menuMode: true); var userSelection = UserInput.SelectMenuOption(mainMenuOptions.Length); switch (mainMenuOptions[userSelection - 1]) { case "Display List of Persons": { MenuHandling.PrintMenuOptions(ourPeeps.ToArray(), messagePrompt: "First Name".PadRight(15) + "Last Name".PadRight(15) + "Age".PadRight(6) + "Email Address".PadRight(20) + "\n" + "==========".PadRight(15) + "=========".PadRight(15) + "===".PadRight(6) + "======================".PadRight(20)); break; } case "Add Person": AddPerson(ourPeeps); break; case "Delete Person": DeletePerson(ourPeeps); break; case "Exit": return; } } //while (true) { //Display list for the first time in the loop //Prompt the user to determine whether or not they want to display list, add Person, or delete Person //} }
public static void DeletePerson(List <Person> masterList) { MenuHandling.PrintMenuOptions(masterList.ToArray(), menuMode: true, messagePrompt: "Here are our peeps:"); var userSelection = UserInput.SelectMenuOption(masterList.Count); YesNoAnswer yesNo = UserInput.GetYesOrNoAnswer("Are you sure? (y/n or yes/no): "); switch (yesNo) { case YesNoAnswer.Yes: masterList.RemoveAt((int)userSelection - 1); break; case YesNoAnswer.No: break; default: break; } }
public static void DeletePerson(List <Person> masterList) { MenuHandling.PrintMenuOptions(masterList.ToArray(), menuMode: true, messagePrompt: $"Here's a list of our peeps. Press 1-{masterList.Count} to delete a person from the list, or {masterList.Count + 1} to go back:"); Console.WriteLine($"{masterList.Count + 1}.) Go back"); //let's allow for the possibility that this method will return one more than the length of the list, just so we have a "go back" option var userSelection = UserInput.SelectMenuOption(masterList.Count + 1); if (userSelection == masterList.Count + 1) { return; } YesNoAnswer yesNo = UserInput.GetYesOrNoAnswer("Are you sure? (y/n or yes/no): "); switch (yesNo) { case YesNoAnswer.Yes: masterList.RemoveAt((int)userSelection - 1); break; case YesNoAnswer.No: break; default: break; } }