static void Main(string[] args) { Console.WriteLine("Would you like to play Pass the Pigs?"); Console.Write("What is your name: "); string name = Console.ReadLine(); while (!IsName(name)) { Console.WriteLine("Please enter your name using only alphabetic characters."); Console.Write("What is your name:"); name = Console.ReadLine(); } Player player1 = new Player(name); Pig pig1 = new Pig(); Pig pig2 = new Pig(); player1.Pig1 = pig1; player1.Pig2 = pig2; Player[] players = { player1 }; try { ChoosePigColors(players[0]); Game(players); } catch (Exception e) { Console.WriteLine("There was an error playing the game. \n" + "\tSorry, we made a mis-steak."); } finally { Console.WriteLine("Thanks for playing!"); Console.ReadKey(); } }
/// <summary> /// Constructs a Player with a name and two Pigs. /// </summary> /// <param name="name">Name of player</param> /// <param name="pig1">First pig that Player is rolling</param> /// <param name="pig2">Second pig that Player is rolling</param> public Player(string name, Pig pig1, Pig pig2) : base() { this.Name = name; this.Pig1 = pig1; this.Pig2 = pig2; }