/// <summary> /// Menu for city statistics. /// </summary> /// <param name="cityStats">A populated statistics object</param> static void CityMenu(Statistics cityStats) { string selection; string titleText = "Cities Menu"; bool displayMenu = true; string dash = new string('-', titleText.Length); do { //Display the menu if (displayMenu) { Console.Clear(); Console.WriteLine($"{dash}\n{titleText}\n{dash}\n"); Console.WriteLine("Available selections:\n"); Console.WriteLine("\t1) Display city's info."); Console.WriteLine("\t2) Display the city with the largest population within a given province."); Console.WriteLine("\t3) Display the city with the smallest population within a given province."); Console.WriteLine("\t4) Compare the population of two cities."); Console.WriteLine("\t5) Display the city on a map."); Console.WriteLine("\t6) Calculate the distance between two cities."); Console.WriteLine("\t7) Update the population of a specific city."); Console.WriteLine("\treturn) Return to the main menu"); Console.Write("\nPlease make a selection (ex. 1, return): "); } displayMenu = true; //Handle response selection = Console.ReadLine(); string response; switch (selection.ToLower()) { case "1": response = GetValidCityName(cityStats); cityStats.DisplayCityInformation(response); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "2": Console.WriteLine("\nWhich province do you wish to see the largest population city of?"); response = GetValidProvince(cityStats); cityStats.DisplayLargestPopulationCity(response); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "3": Console.WriteLine("\nWhich province do you wish to see the smallest population city of?"); response = GetValidProvince(cityStats); cityStats.DisplaySmallestPopulationCity(response); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "4": Console.WriteLine("\nWhich city do you want to pick first?"); CityInfo city1 = GetCityChoiceObject(cityStats); Console.WriteLine("\nWhich city do you want to compare it to?"); CityInfo city2 = GetCityChoiceObject(cityStats); cityStats.CompareCitiesPopulation(city1, city2); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "5": Console.WriteLine("\nWhich city do you want to see on the map?"); CityInfo city = GetCityChoiceObject(cityStats); cityStats.ShowCityOnMap($"{city.GetCityName().ToLower()}|{city.GetProvince().ToLower()}"); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "6": Console.WriteLine("\nWhich city do you want to start at?"); CityInfo startingCity = GetCityChoiceObject(cityStats); Console.WriteLine("\nWhich city do you want to calculate the distance to?"); CityInfo endingCity = GetCityChoiceObject(cityStats); cityStats.CalculateDistanceBetweenCities(startingCity, endingCity).Wait(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "7": UpdatePopulation(cityStats); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; case "return": return; default: Console.Write("\nInvalid selection, please enter a valid selection: "); displayMenu = false; break; } } while (true); }