Yatzy { public static int three_of_a_kind(int d1, int d2, int d3, int d4, int d5) { int[] t; t = new int[6]; t[d1-1]++; t[d2-1]++; t[d3-1]++; t[d4-1]++; t[d5-1]++; for (int i = 0; i < 6; i++) if (t[i] >= 3) return (i+1) * 3; return 0; } Yatzy(int d1, int d2, int d3, int d4, int _5); static int chance(int d1, int d2, int d3, int d4, int d5); static int yatzy(int... dice); static int ones(int d1, int d2, int d3, int d4, int d5); static int twos(int d1, int d2, int d3, int d4, int d5); static int threes(int d1, int d2, int d3, int d4, int d5); int fours(); int fives(); int sixes(); static int score_pair(int d1, int d2, int d3, int d4, int d5); static int two_pair(int d1, int d2, int d3, int d4, int d5); static int four_of_a_kind(int _1, int _2, int d3, int d4, int d5); static int three_of_a_kind(int d1, int d2, int d3, int d4, int d5); static int smallStraight(int d1, int d2, int d3, int d4, int d5); static int largeStraight(int d1, int d2, int d3, int d4, int d5); static int fullHouse(int d1, int d2, int d3, int d4, int d5);  }
@Test public void three_of_a_kind() { assertEquals(9, Yatzy.three_of_a_kind(3,3,3,4,5)); assertEquals(15, Yatzy.three_of_a_kind(5,3,5,4,5)); assertEquals(9, Yatzy.three_of_a_kind(3,3,3,3,5)); }