Ejemplo n.º 1
0
        /// <summary>
        /// Draws a given object to the console from string.
        /// </summary>
        /// <param name="drawableObject">Accept any instance of IDrawable.</param>
        public void DrawObject(IDrawable drawableObject)
        {
            string objectsToDraw = drawableObject.BitMap();

            for (int i = 0; i < drawableObject.BitMap().Length; i++)
            {
                if (objectsToDraw[i] >= '0' && objectsToDraw[i] <= '9')
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }

                if (objectsToDraw[i] == 'X')
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }

                Console.Write(objectsToDraw[i]);
                Console.ResetColor();
            }
        }