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();
}
}
}
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: