@Test public void colorsAvailableComplete() { List<LetterSource> availableLetters = Arrays.asList( TestUtil.createLetterSource("O"), TestUtil.createLetterSource("A"), TestUtil.createLetterSource("B"), TestUtil.createLetterSource("C"), TestUtil.createLetterSource("D")); int[] colors = WordUtil.getWordColors(availableLetters, "OK"); assertEquals(2, colors.length); assertEquals(WordUtil.COLOR_ONE, colors[0]); assertEquals(WordUtil.COLOR_COMBO, colors[1]); }
public static int[] getWordColors(List<LetterSource> letters, String word) { int[] colors = new int[word.length()]; if (letters == null) { for (int i = 0; i < colors.length; ++i) { colors[i] = COLOR_MISSING; } return colors; } SpelledWord spelledWord = WordUtil.spell(letters, word); return getWordColors(spelledWord.letters); }
WordUtil { public static int[] getWordColors(List<LetterSource> letters, String word) { int[] colors = new int[word.length()]; if (letters == null) { for (int i = 0; i < colors.length; ++i) { colors[i] = COLOR_MISSING; } return colors; } SpelledWord spelledWord = WordUtil.spell(letters, word); return getWordColors(spelledWord.letters); } }
WordUtil { public static int[] getWordColors(List<LetterSource> letters, String word) { int[] colors = new int[word.length()]; if (letters == null) { for (int i = 0; i < colors.length; ++i) { colors[i] = COLOR_MISSING; } return colors; } SpelledWord spelledWord = WordUtil.spell(letters, word); return getWordColors(spelledWord.letters); }  }
WordUtil { public static int[] getWordColors(List<LetterSource> letters, String word) { int[] colors = new int[word.length()]; if (letters == null) { for (int i = 0; i < colors.length; ++i) { colors[i] = COLOR_MISSING; } return colors; } SpelledWord spelledWord = WordUtil.spell(letters, word); return getWordColors(spelledWord.letters); }  static SpelledWord spell(List<LetterSource> letters, String word); static int[] getWordColors(List<LetterSource> letters, String word); static int[] getWordColors(List<SpelledLetter> letters); }
WordUtil { public static int[] getWordColors(List<LetterSource> letters, String word) { int[] colors = new int[word.length()]; if (letters == null) { for (int i = 0; i < colors.length; ++i) { colors[i] = COLOR_MISSING; } return colors; } SpelledWord spelledWord = WordUtil.spell(letters, word); return getWordColors(spelledWord.letters); }  static SpelledWord spell(List<LetterSource> letters, String word); static int[] getWordColors(List<LetterSource> letters, String word); static int[] getWordColors(List<SpelledLetter> letters); static final int COLOR_MISSING; static final int COLOR_ONE; static final int COLOR_COMBO; }