static void Main(string[] args) { Console.WriteLine("숫자야구 프로그램\n"); BullsAndCows game = new BullsAndCows(); bool gameContinue = true; while (gameContinue == true) { game.Setup(); game.Play(); while (true) { Console.Write("계속하시겠습니까? (y/n) : "); string input = Console.ReadLine(); if (input == "y") { gameContinue = true; break; } else if (input == "n") { gameContinue = false; break; } else { Console.WriteLine("잘못된 입력입니다.\n"); } } } }
static void Main() { BullsAndCows Start = new BullsAndCows(); numberLength = Start.Input(); Start.Randomizer(); Console.WriteLine("FinalRandom = {0}", finalRandom); Start.Looped_call(); }
public bool IsSame(BullsAndCows other) { if (other.Bulls == Bulls && other.Cows == Cows) { return(true); } else { return(false); } }
private void ReducePossibelNumbers() { for (int i = 0; i < allPossibleNumber.Count;) { BullsAndCows response = GetBullsCowsResponse(allPossibleNumber[i], currentGuessNumber); if (!IsSame(response)) { allPossibleNumber.RemoveAt(i); } else { i++; } } }
public static BullsAndCows GetBullsCowsResponse(string secretNumberArray, string guessNumber) { BullsAndCows result = new BullsAndCows(); for (int i = 0; i < secretNumberArray.Length; i++) { string digit = secretNumberArray[i].ToString(); int index = guessNumber.IndexOf(digit); if (index == i) { result.Bulls++; } else if (index >= 0) { result.Cows++; } } return(result); }
public static void Main() { BullsAndCows game = new BullsAndCows(); game.StartGame(); }
static void Main() { BullsAndCows game = new BullsAndCows(); game.Play(); }