private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(@Constants.fileName); List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); if (matchedWords == null) { Console.WriteLine(Constants.noWordsError); } else if (!(matchedWords == null)) { foreach (var s in matchedWords) { // String formattingWord= String.Format("MATCH FOUND FOR{0}{1}", s.scrambledWords, wordList); /*String scrambledWordsFormatted = s.ScrambledWord; * String wordWordFormatted = s.Word;*/ Console.WriteLine(Constants.matchFound + s.ScrambledWord + " " + s.Word); // Console.WriteLine(formattingWord); } } }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { //Console.WriteLine("test4"); string[] wordList = fileReader.Read(Constants.RegWordText); // Put in a constants file. CAPITAL LETTERS. READONLY. THIS FILE IS READ List <MatchedWord> matchedWords = new List <MatchedWord>(); matchedWords = wordMatcher.Match(scrambledWords, wordList); //Console.WriteLine("test5"); // Rule: Use a formatter to display ... eg: {0}{1} // Rule: USe an IF to determine if matchedWords is empty or not...... // if empty - display no words found message. // if NOT empty - Display the matches.... use "foreach" with the list (matchedWords) if (!matchedWords.Any()) { Console.WriteLine(Constants.NoMatch); } else { //Console.WriteLine("test6"); foreach (var Matchedword in matchedWords) { //from MatchedWord.cs ---->Matchedword.ScrambledWord, Matchedword.Word) Console.WriteLine(String.Format(Constants.YesMatch, Matchedword.ScrambledWord, Matchedword.Word)); } } }
// Finished DisplayMatchedScrambledWords Method - Justin. M private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(Constants.WORDLIST); List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); if (matchedWords == null) { Console.WriteLine(Constants.NOFOUNDMSG); } else { foreach (MatchedWord matche in matchedWords) { Console.WriteLine("MATCH FOUND FOR {0}: {1}", matche.ScrambledWord, matche.Word); } } // Rule: Use a formatter to display ... eg: {0}{1} // Rule: USe an IF to determine if matchedWords is empty or not...... // if empty - display no words found message. // if NOT empty - Display the matches.... use "foreach" with the list (matchedWords) }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(@"wordlist.txt"); // Put in a constants file. CAPITAL LETTERS. READONLY. List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); // Rule: Use a formatter to display ... eg: {0}{1} // Rule: USe an IF to determine if matchedWords is empty or not...... // if empty - display no words found message. // if NOT empty - Display the matches.... use "foreach" with the list (matchedWords) }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(ConstantsFile.WordList); List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); if (matchedWords.Count == 0) { Console.WriteLine("No words found."); } else { foreach (MatchedWord s in matchedWords) { Console.WriteLine("Words {0} and {1} match", s.ScrambledWord, s.Word); } } }
private static void ExecuteScrambledWordsManualEntryScenario() { string userInput = Console.ReadLine(); WordMatcher matcher = new WordMatcher(); var thisExeDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string filePath = Path.Combine(thisExeDirectory, "wordlist.txt"); if (!File.Exists(filePath)) { Console.WriteLine("File does not exist"); return; } FileReader reader = new FileReader(); string[] arrStrings = reader.Read(filePath); if (arrStrings.Length == 0) { Console.WriteLine("File is empty"); return; } string[] scrambledWords = userInput.Split(','); List <MatchedWord> matchedWords = matcher.Match(scrambledWords, arrStrings); foreach (MatchedWord word in matchedWords) { Console.WriteLine(word.ScrambledWord + " = " + word.Word); } // 3 Call the DisplayMatchedUnscrambledWords method passing the scrambled words string array }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(@"wordlist.txt"); // Put in a constants file. CAPITAL LETTERS. READONLY. List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); // Rule: Use a formatter to display ... eg: {0}{1} if (!matchedWords.Any()) { Console.WriteLine("no words found"); } else { foreach (MatchedWord s in matchedWords) { String display = String.Format("MATCH FOUND FOR{0}{1}", scrambledWords, wordList); } } // Rule: USe an IF to determine if matchedWords is empty or not...... // if empty - display no words found message. // if NOT empty - Display the matches.... use "foreach" with the list (matchedWords) }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(@"wordlist.txt"); // Put in a constants file. CAPITAL LETTERS. READONLY. List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); if (matchedWords == null) { Console.WriteLine(Constants.file_path_invalid); } else if (matchedWords.Any()) { foreach (var mw in matchedWords) { Console.WriteLine(Constants.matched_found, mw.ScrambledWord, mw.Word); } } else { Console.WriteLine(Constants.no_match_found); } }
private static void DisplayMatchedScrambledWords(string[] scrambledWords) { string[] wordList = fileReader.Read(Constants.WORDLIST); // Put in a constants file. CAPITAL LETTERS. READONLY. List <MatchedWord> matchedWords = wordMatcher.Match(scrambledWords, wordList); // Rule: Use a formatter to display ... eg: {0}{1} // Rule: USe an IF to determine if matchedWords is empty or not...... // if empty - display no words found message. if (matchedWords == null) { Console.WriteLine("No words found"); } // if NOT empty - Display the matches.... use "foreach" with the list (matchedWords) else { foreach (MatchedWord mw in matchedWords) { Console.WriteLine("Match found for the word {0} which is equal to {1}", mw.ScrambledWord, mw.Word); } } }