Question: visual studio C# 2012 tic tac toe simulator Hi, i am doing a tic tac toe simulator on visual studio, and we are using WPF.

visual studio C# 2012 tic tac toe simulator

Hi, i am doing a tic tac toe simulator on visual studio, and we are using WPF.

I did mine to a point where I dont understand how to make the label tell or say X win or O win. I show you guys on how far I am, but now I am stuck. I hope someone can show me a demo on the tic tac toe simulator or show an example, but here is mine, it not finish, so I need help.

private void btnNewGame_Click(object sender, RoutedEventArgs e) { Random rand = new Random(); const int ROWS = 3; const int COLS = 9; int[,] values = new int[ROWS, COLS];

for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { values[row, col] = rand.Next(2); lblA1.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblA2.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblA3.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblB1.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblB2.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblB3.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblC1.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblC2.Content = (values[row, col] == 0) ? "O" : "X";

values[row, col] = rand.Next(2); lblC3.Content = (values[row, col] == 0) ? "O" : "X";

}

if ((lblA1.Content == lblA2.Content) && (lblA2.Content == lblA3.Content)) { lblAnswer.Content = "win"; } else lblAnswer.Content = "It a Tie";

if ((lblB1.Content == lblB2.Content) && (lblB2.Content == lblB3.Content)) { lblAnswer.Content = "win"; } else lblAnswer.Content = "It a tie";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!