Hey guys, my computer science teacher gave us this code for a tictactoe game. What he wants us to do with it is to type in a code into the entire program that will determine the winner of the tictactoe game. The problem is, I don't know where to start.
P.S sorry if the code is so long.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Randell_tictactoe
{
public partial class Form1 : Form
{
Rectangle[,] tictactoe;
int[,] board;
int player = 0;
public Form1()
{
InitializeComponent();
board = new int[3, 3];
tictactoe = new Rectangle[3, 3];
int i = 0;
int j = 0;
while (i <= 2)
{
while (j <= 2)
{
board[i, j] = 0;
j++;
}
j = 0;
i++;
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
int x, y;
x = tictactoe.GetLength(0);
y = tictactoe.GetLength(1);
Pen pn = new Pen(Color.Black, 2);
Graphics g = e.Graphics;
int i = 0;
int j = 0;
int a, b;
a = ClientRectangle.Width;
b = ClientRectangle.Height;
int storex, storey;
while (i <= x - 1)
{
while (j <= y - 1)
{
tictactoe[i, j] = new Rectangle(i * (a / 3), j * (b / 3), a / 3, b / 3);
g.DrawRectangle(pn, tictactoe[i, j]);
j++;
}
j = 0;
i++;
}
i = 0;
j = 0;
while (i <= x - 1)
{
while (j <= y - 1)
{
if (board[i, j] == 1)
{
storex = tictactoe[i, j].X;
storey = tictactoe[i, j].Y;
g.DrawLine(pn, storex, storey, storex + (a / 3), storey + b / 3);
g.DrawLine(pn, storex, storey + b / 3, storex + (a / 3), storey);
}
else if (board[i, j] == 2)
{
g.DrawEllipse(pn, tictactoe[i, j].X, tictactoe[i, j].Y, a / 3, b / 3);
}
j++;
}
j = 0;
i++;
}
ResizeRedraw = true;
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
int i = 0;
int j = 0;
while (i <= 2)
{
while (j <= 2)
{
if (board[i, j] == 0 && player == 0&& tictactoe[i,j].Contains(e.X,e.Y))
{
board[i, j] = 1;
player = 1;
Invalidate();
}
else if (board[i, j] == 0 && player == 1 & tictactoe[i, j].Contains(e.X, e.Y))
{
board[i, j] = 2;
player = 0;
Invalidate();
}
j++;
}
j = 0;
i++;
}
}
}
}