Exemplo n.º 1
0
    public static void Main()
    {
        // Change console's output encoding to UTF-8.
        Console.OutputEncoding = System.Text.Encoding.UTF8;
        // Create an object of class Turtle and call it "donatello". Why not? He is a programmer too.
        Turtle donatello = new Turtle();
        // Create an object of class ConsoleKey and assign it to any key we don't use in the app (Space Bar).
        ConsoleKey keyPressed = ConsoleKey.Spacebar;

        // While user don't press "ESC" button.
        while (keyPressed != ConsoleKey.Escape)
        {
            // Clear Console window from any previous characters.
            Console.Clear();
            // Call donatello's "DisplayCommands()" method, which prints a hint for a user with all possible commands.
            donatello.DisplayCommands();
            // Call donatello's "PrintAnArray()" method to print two-dimentional array.
            donatello.PrintAnArray();
            // Read a key pressed by a user and assign it to "keyPressed" local variable.
            keyPressed = Console.ReadKey(true).Key;
            // Call donatello's "PerformAnAction()" method, which perform different actions (if do) depending on key pressed.
            donatello.PerformAnAction(keyPressed);
        }
    }