日期:2014-05-20 浏览次数:20824 次
import java.io.IOException;
import java.util.Random;
public class ComputerPlay {
public int Crow;
public int Ccol;
public void computerPlay() throws Exception{
try{
Random rand = new Random();
Crow = rand.nextInt(3)-1;
Ccol = rand.nextInt(3)-1;
} catch (ArrayIndexOutOfBoundsException e){
computerPlay();
}
//computerPlay();
if(ChessPad.board[Crow][Ccol] == ChessPad.EMPTY){
ChessPad.board[Crow][Ccol] = ChessPad.CROSS;
}
}
}