@Test public void colorsSpelledComplete() { LetterSource letterO = TestUtil.createLetterSource("O"); LetterSource letterA = TestUtil.createLetterSource("A"); LetterSource letterB = TestUtil.createLetterSource("B"); LetterSource letterC = TestUtil.createLetterSource("C"); LetterSource letterD = TestUtil.createLetterSource("D"); letterD.available = 0; LetterSource letterE = TestUtil.createLetterSource("E"); List<LetterSource> letters = Arrays.asList( letterO, letterA, letterB, letterC, letterD, letterE); int[] colors = WordUtil.getWordColors(letters, "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; }