public static void searchName(LinkedList List, stopwatch timer) { string name = getUserName(); timer.startTimer(); Node searchedName = List.search(name); timer.stopTimer(); if (searchedName == null) { Console.WriteLine("time taken to not find this name was " + timer.outputTime()); Console.WriteLine(name + " was not found in our list would you like to add it? \n if so press Y"); if (Console.ReadKey().Key == ConsoleKey.Y) { Console.WriteLine(); userAddName(List, name, timer); } } else { Console.WriteLine("time taken to find this node was" + timer.outputTime()); string nameData = searchedName.getUserInfo(); Console.WriteLine(nameData); } }
public static void userAddName(LinkedList List, string name, stopwatch timer) { Console.WriteLine("Please enter the gender for your person only M or F."); string gender = getUserGender(); Console.WriteLine(); Console.WriteLine("Please enter how popular the name is using numbers."); int popularity = parseinput(); Node userAdded = List.search(name, gender); //if name entered did not exist if (userAdded == null) { Console.WriteLine("That name was not found in the list it has been added to the list."); timer.startTimer(); List.add(name, gender, popularity); timer.stopTimer(); Console.WriteLine("time taken to add this node was " + timer.outputTime()); } else if (userAdded != null)//if name does exist { Console.WriteLine("that name is currently in the list, would you like to add it with a suffex of _1? \n press y if you want to add them"); if (Console.ReadKey().Key == ConsoleKey.Y) { Console.WriteLine(name + " will be entered with _1 suffex thank you for your response"); name = name + "_1"; timer.startTimer(); List.add(name, gender, popularity); timer.stopTimer(); Console.WriteLine("time taken to add this node with suffex was " + timer.outputTime()); } else { Console.WriteLine(name + " was not added with the suffex"); } return; } }