public void Run() { writer.ClearInterface(); writer.PrintOnNewLine(MenuMessages.resolverMenu); string characters = reader.ReadNewLine().Replace(" ", String.Empty).ToLower(); bool passed = true; while (passed) { if (wordOperator.SolverValidation(characters)) { passed = false; List <string> solutions = wordOperator.FindingSoutions(characters); if (!(solutions.Count == 0)) { writer.PrintOnNewLine(MenuMessages.solverMessage); foreach (string solution in solutions) { writer.PrintOnNewLine(solution); } } } else { characters = reader.ReadNewLine().Replace(" ", String.Empty); } } }
public void RunLevel() { string characters = wordOperator.Shuffle(wordOperator.GivingRandomWordWithNLenght(Int32.Parse(chosenLevel))); List <string> soutions = wordOperator.FindingSoutions(characters); PrintLevelStartingPoint(characters); string attempt = reader.ReadNewLine(); while (true) { if (attempt == CommandConstants.SURRENDER_COMMAND) { writer.PrintOnNewLine(MenuMessages.wordsLeft); soutions.ForEach(x => writer.PrintOnNewLine("->" + x)); break; } if (attempt == CommandConstants.CLEAR_COMMAND) { PrintLevelStartingPoint(characters); attempt = reader.ReadNewLine(); continue; } if (attempt != null && !wordOperator.AtemptValidation(characters.Trim(), attempt.Trim())) { writer.PrintOnNewLine(MenuMessages.invalidInput); attempt = reader.ReadNewLine(); continue; } if (trieFromDictionary.Search(attempt)) { soutions.Remove(attempt); writer.PrintOnNewLine(attempt + @" is valid word!"); player.Score += attempt.Length; writer.PrintOnNewLine(soutions.Count + " words left."); } else { writer.PrintOnNewLine(attempt + " is not valid word!"); } if (soutions.Count == 0) { writer.PrintOnNewLine(MenuMessages.wordsSolved); break; } attempt = reader.ReadNewLine(); } }