public void Run(IUiHandler uiHandler) { bool presence = true; string randomWord = _wordsRepository.GetRandomWord(); var anagrams = _wordsRepository.GetAnagrams(randomWord); while (presence) { /*if (anagrams.Count > 1) * presence = false; * else * anagrams = _wordsRepository.GetAnagrams(randomWord); * uiHandler.WriteMessage(anagrams[1]);*/ } uiHandler.WriteMessage($"\nHere's the word: { randomWord }\nNow insert a word and i'll tell you if it's an anagram"); string userWord = uiHandler.AskForString(""); for (int i = 0; i > anagrams.Count; i++) { if (userWord.Equals(anagrams[i])) { uiHandler.WriteMessage($"{anagrams[i]}\n"); presence = true; } } if (!presence) { uiHandler.WriteMessage("Your word is no anagram"); } }
public GamePlay(string description, IUiHandler uiHandler) { if (description != null && uiHandler != null) { Description = description; UiHandler = uiHandler; } else { throw new Exception("Invalid parameter"); } }
int GetMenuOption(List <GamePlay> gamePlayList, IUiHandler uiHandler) { int index = 1; uiHandler.WriteMessage($"Please choose what game you wish to play\n\r"); foreach (GamePlay gamePlay in gamePlayList) { uiHandler.WriteMessage($"{index++} - {gamePlay.Description}"); } uiHandler.WriteMessage($"\n\r0 - to exit..."); return(uiHandler.InsertInt(0, gamePlayList.Count())); }
public void Run(IUiHandler uiHandler) { string word = uiHandler.AskForString(""); var anagrams = _wordsRepository.GetAnagrams(word); if (anagrams.Count > 1) { uiHandler.WriteMessage($"I found these anagrams:"); foreach (var anagram in anagrams) { uiHandler.WriteMessage(anagram); } } else { uiHandler.WriteMessage("\nI didn't find any anagrams"); } }
public Game( Func <Size, IShipGenerationService> shipGenerationServiceFactory, Func <Size, IReadOnlyList <IShip>, IBoard> boardFactory, [KeyFilter(ShipFactoryType.Battleship)] Func <IShipFactory> battleshipFactory, [KeyFilter(ShipFactoryType.Destroyer)] Func <IShipFactory> destroyerFactory, IUiHandler uiHandler ) { this.boardSize = new Size(BoardDimension, BoardDimension); this.shipGenerationService = shipGenerationServiceFactory(boardSize); this.boardFactory = boardFactory; this.battleshipFactory = battleshipFactory; this.destroyerFactory = destroyerFactory; this.uiHandler = uiHandler; this.GameStarted += uiHandler.OnGameStarted; this.GameFinished += uiHandler.OnGameFinished; this.board = GetNewBoard(); }
public Training(string description, IUiHandler uiHandler) : base(description, uiHandler) { }
public UserContoller(IUserModel userModel, IUiHandler uiHandler) { // For constructor injection during unit testing _userModel = userModel; _uiHandler = uiHandler; }
public UserContoller() { _userModel = new UserModel(new UserRepository()); _uiHandler = new UiHandler(); }
public Challenge(string description, IUiHandler uiHandler) : base(description, uiHandler) { }