private static void test(List<int> number1, List<int> number2, JudgeResult answer) { GameMaster master = new GameMaster(); JudgeResult result = master.Judge(number1, number2); Assert.AreEqual(result.Eat, answer.Eat); Assert.AreEqual(result.Bite, answer.Bite); }
/// <summary> /// 判定 /// </summary> public JudgeResult Judge(List<int> number1, List<int> number2) { // 数値チェック if ((!CheckNumber(number1)) || (!CheckNumber(number2))) { return new JudgeResult { Eat = -1, Bite = -1 }; } JudgeResult result = new JudgeResult { Eat = 0, Bite = 0 }; // EATの判定 for (int i = 0; i < number1.Count; i++) { // 桁と数一致 if (number1[i] == number2[i]) { result.Eat++; } else { // 数だけ一致 if (number1[i] == number2[0]) { result.Bite++; } else if (number1[i] == number2[1]) { result.Bite++; } else if (number1[i] == number2[2]) { result.Bite++; } } } return result; }
void INumeronAI.SetResult(List<int> number, JudgeResult result) { }