Example #1
0
        static void PlayerPlay()
        {
            Console.WriteLine();
            Console.WriteLine("Would you like to break the 'right', 'left', 'top', or 'bottom' boundry?");
            string input = Console.ReadLine();

            // The gameboard is immutable. This means that every new turn, we instantiate
            // a new gameboard from the old one. That is a safety check on myself and prevents weird
            // things from happening.
            switch (input.ToLower())
            {
            case "right":
                chocolateBar.TrimRight();
                break;

            case "left":
                chocolateBar.TrimLeft();
                break;

            case "top":
                chocolateBar.TrimTop();
                break;

            case "bottom":
                chocolateBar.TrimBottom();
                break;

            default:
                Console.WriteLine("I'm sorry, I did not understand that.");
                PlayerPlay();
                break;
            }
        }
Example #2
0
 private bool TryBreakTop()
 {
     if (!chocolateBar.rowContainsSpoiled(0))
     {
         chocolateBar.TrimTop();
         Console.WriteLine("The AI broke the top.");
         return(true);
     }
     return(false);
 }