diff --git a/src/main/java/com/hangman/players/YourPlayer.java b/src/main/java/com/hangman/players/YourPlayer.java index ddcfbd3..db3fefd 100644 --- a/src/main/java/com/hangman/players/YourPlayer.java +++ b/src/main/java/com/hangman/players/YourPlayer.java @@ -1,13 +1,29 @@ package com.hangman.players; import com.hangman.Player; - -import java.util.Arrays; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; public class YourPlayer implements Player { + + public List alphabet = new ArrayList(); + private List guessedLetters = new ArrayList(); + @Override public char GetGuess(List currentClue) { - return 'a'; + buildAlphabet(); + char letter = alphabet.get(0); + guessedLetters.add(letter); + return letter; + } + + public List GetGuessedLetters() { + return guessedLetters; + } + + private void buildAlphabet() { + for (int i = 'a'; i <= 'z'; i++) { + System.out.print(i); + alphabet.add((char)i); + } } } diff --git a/src/test/java/com/hangman/players/YourPlayerTest.java b/src/test/java/com/hangman/players/YourPlayerTest.java index d613f6b..1e42ed2 100644 --- a/src/test/java/com/hangman/players/YourPlayerTest.java +++ b/src/test/java/com/hangman/players/YourPlayerTest.java @@ -2,7 +2,9 @@ import org.junit.Test; import java.util.Arrays; -import static org.junit.Assert.assertEquals; +import java.util.List; +import java.util.ArrayList; +import static org.junit.Assert.*; public class YourPlayerTest { @Test @@ -11,7 +13,7 @@ public void GuessesAWhenThereAreNoSuccessfulCharactersGuessedYet() { char guess = player.GetGuess(Arrays.asList('_', '_', '_')); - assertEquals('a', guess); + assertTrue(player.alphabet.contains(guess)); } @Test @@ -31,4 +33,17 @@ public void GuessesAWhenAIsThereAreAsInTheClueAsWell() { assertEquals('a', guess); } + + @Test + public void AddLetterToGuessedListAfterGuess() { + YourPlayer player = new YourPlayer(); + + player.GetGuess(Arrays.asList('_', '_', '_')); + List guessedLetters = player.GetGuessedLetters(); + + List expectedList = new ArrayList(); + expectedList.add('a'); + + assertEquals(expectedList, guessedLetters); + } }