Feren Silver
Hero

I'm having some problems. I can't get it so that just one picture can be in a square (in mine, an O can take the spot X picked). Also, I need a restart button in the case that a cats game occurs.
Here is the code I have so far:
Any and all help is greatly appreciated.
Here is the code I have so far:
Code:
/**
// the TicTacToe.htm file contains an "archive" parameter that
// helps the browswer find the objectdraw.jar
import objectdraw.WindowController;
import objectdraw.FilledRect;
import objectdraw.Location;
import objectdraw.*;
import java.awt.Color;
import java.awt.*;
public class TicTacToe extends WindowController
{
private TicTacToeSpot[][] ttt;
private Image empty,x,y;
private boolean isX,win;
public void begin()
{
isX = true;
win = false;
ttt = new TicTacToeSpot[3][3];
empty = getImage("empty20.gif");
x = getImage("x2.gif");
y = getImage("o2.gif");
for(int i = 0; i < 300; i+=100)
{
for (int j = 0; j < 300; j+=100)
{
ttt[i/100][j/100] = new TicTacToeSpot(empty, i,j,canvas);
}
}
}
public void onMouseClick(Location point)
{
int r = (int)point.getX()/100;
int c = (int)point.getY()/100;
if (isX)
{
//THIS IS WHERE THE CODE NEEDS TO BE EDITED TO FIX IT SO THAT TWO IMAGES CAN'T BE PLACED OVER ONE ANOTHER.
ttt[r][c].setSpot('x');
ttt[r][c].setImage(x,r,c);
}
else
{
ttt[r][c].setSpot('o');
ttt[r][c].setImage(y,r,c);
}
checkwin();
if (!win)isX = !isX;
if (win)
{
canvas.clear();
begin();
}
}
public void checkwin()
{
char spot;
if (isX) spot = 'x'; else spot = 'o';
for (int i = 0; i < 3&& !win; i++)
{
if(ttt[i][0].getSpot()==spot &&ttt[i][1].getSpot()==spot &&ttt[i][2].getSpot()==spot)
{
win = true;
}
if(ttt[0][0].getSpot()==spot &&ttt[1][1].getSpot()==spot &&ttt[2][2].getSpot()==spot)
{
win = true;
}
if(ttt[0][2].getSpot()==spot &&ttt[1][1].getSpot()==spot &&ttt[2][0].getSpot()==spot)
{
win = true;
}
}
for (int j = 0; j < 3 && !win;j++)
{
if(ttt[0][j].getSpot()==spot&&ttt[1][j].getSpot()==spot&&ttt[2][j].getSpot()==spot)
{
win = true;
}
}
System.out.println(win);
}
Any and all help is greatly appreciated.

