public static void GetLongestWordData() { var myWordMngr = new WordManager();//this is an instance of WordManager string userInput; Console.Clear(); var msg = new StringBuilder(); msg.AppendLine("Thanks for choosing the Longest Word Exercise."); Console.WriteLine(msg); do { Console.Write("Please enter a list of words separated by a space: "); userInput = Console.ReadLine().ToLower(); } while (!Utilities.IsValidInputAlpha("Alpha", userInput)); #region Old user input code //do //{ // Console.Write("Please enter a word: "); // longest1 = Console.ReadLine(); //} while (!Utilities.IsValidInputAlpha("Alpha", longest1)); //do //{ // Console.Write("Please enter a word: "); // longest2 = Console.ReadLine(); //} while (!Utilities.IsValidInputAlpha("Alpha", longest2)); #endregion Console.WriteLine(myWordMngr.longestWord(userInput)); }
public static void GetWordFreqData() { var wordMngr = new WordManager(); //this is an instance of WordManager class string userInput; Console.Clear(); var msg = new StringBuilder(); msg.AppendLine("Thanks for choosing the Word Frequency Exercise."); Console.WriteLine(msg); do { Console.Write("Please enter a list of words separated by a space: "); userInput = Console.ReadLine().ToLower(); }while (userInput == ""); #region Old userinput code //do //{ // Console.Write("Please enter a word: "); // freq2 = Console.ReadLine(); //} //while (freq2 == ""); //do //{ // Console.Write("Please enter a word: "); // freq3 = Console.ReadLine(); //} //while (freq3 == ""); //do //{ // Console.Write("Please enter a word: "); // freq1 = Console.ReadLine(); //} //while (freq4 == ""); //do //{ // Console.Write("Please enter a word: "); // freq1 = Console.ReadLine(); //} //while (freq5 == ""); #endregion Console.WriteLine(wordMngr.wordFrequency(userInput)); }
public static void GetLongWordData() //has notes about logging output to console for a non-static method (see WordManager) { var myWordMngr = new WordManager(); //instance of class WordManager; WordManager = class, and we're creating a new type string length; string userInput; Console.Clear(); var msg = new StringBuilder(); msg.AppendLine("Thanks for choosing the Longest Word Compared to an Integer Exercise."); Console.WriteLine(msg); do { Console.Write("Please enter a number: "); length = Console.ReadLine();//can't convert user input to integer }while (!Utilities.IsValidInput(length)); do { Console.Write("Please enter a list of words separated by a space: "); userInput = Console.ReadLine().ToLower(); } while (!Utilities.IsValidInputAlpha("Alpha", userInput)); #region Old code for user input //do //{ // Console.Write("Please enter a word: "); // word2 = Console.ReadLine(); //} while (!Utilities.IsValidInputAlpha("Alpha", word2)); //do //{ // Console.Write("Please enter a word: "); // word3 = Console.ReadLine(); //} while (!Utilities.IsValidInputAlpha("Alpha", word3)); #endregion Console.WriteLine(myWordMngr.longestInteger(Convert.ToInt32(length), userInput));//converted length that was a string because of user input to integer //longestInteger = name of method; (length, word1, etc...) = method inputs }
public static void GetPalindromeData() { var myWordMgr = new WordManager(); //this is an instance of class WordManager string palin1; //empty variable Console.Clear(); var msg = new StringBuilder(); msg.AppendLine("Thanks for choosing Palindrome Exercise. Enter a word below:"); Console.WriteLine(msg); do { Console.Write("Please enter a word: "); palin1 = Console.ReadLine().ToLower(); //makes all characters lowercase } while (!Utilities.IsValidInputAlpha("Alpha", palin1)); Console.WriteLine("Your word is a Palindrome: " + myWordMgr.Palindrome(palin1)); }