dramire83 / CIS_285

CIS_285
0 stars 0 forks source link

Code - printBoard Method #23

Closed jwood36 closed 1 year ago

jwood36 commented 1 year ago

You have three decision blocks that perform the same logic inside and your conditions within each are basically the same condition with a minor variable of the Right-Operand changing.

Evaluate this condition sequence and see how you can minimize its current design to simplify the logic.

For my Reference:

        private static void printBoard()
        {
            Console.WriteLine(" ");
            for (int i = 0; i < 9; i++)
            {
                //Print an X or O for each square
                //0 = unoccupied 

                if (board[i] == 0)
                {
                    Console.Write("   .   ");
                }
                if (board[i] == 8)
                {
                    Console.Write("   X   ");
                }
                if (board[i] == 9)
                {
                    Console.Write("   O   ");
                }

                //Print a new line every 3rd character
                if (i == 2 || i == 5 || i == 8)
                {
                    Console.WriteLine();
                }
            }
        }
dramire83 commented 1 year ago

Have executed refactoring over all methods/functions and created a better streamline Object-oriented design.