using System; using System.Collections.Generic; using System.Text; namespace ArrayThing { class Program { static int NUM_HOLES = 20; static void printHoles(char[] holes) { for (int j = 0; j < NUM_HOLES; j++) { if (holes[j] == 'X') { Console.Write("|" + " "); } else { Console.Write("|" + holes[j]); } } Console.WriteLine("|"); } static void initHoles(char[] holes) { // Initialize the array for (int i = 0; i < NUM_HOLES; i++) { holes[i] = ' '; } // Put the rabbit in the hole Random rand = new Random(); int rabbitSpot = rand.Next(NUM_HOLES); holes[rabbitSpot] = 'X'; } static bool isRabbitThere(char[] holes, int userGuess) { if (holes[userGuess] == 'X') { return true; } else { return false; } } static void Main(string[] args) { char[] holes = new char[NUM_HOLES]; int userChoice = 4000; initHoles(holes); printHoles(holes); Console.WriteLine("Where's the rabbit?"); userChoice = Int32.Parse(Console.ReadLine()); while (userChoice != -1) { if (isRabbitThere(holes, userChoice)) { Console.WriteLine("You rock my world!"); userChoice = -1; } else { holes[userChoice] = '#'; Console.WriteLine("Try again"); Console.WriteLine("Where's the rabbit?"); printHoles(holes); userChoice = Int32.Parse(Console.ReadLine()); } } } } }