回复 2楼 Kingbox_tang
import java.awt.event.InputEvent;
import
import
public class Gobang
{
private String[][] board;
private static int BOARD_SIZE=15;
public void initBoard()
{
board=new String[BOARD_SIZE][BOARD_SIZE];
for(int i=0;i<BOARD_SIZE;i++)
{
for(int j=0;j<BOARD_SIZE;j++)
{
board[i][j]="╋";
}
}
}
public void printBoard()
{
for(int i=0;i<BOARD_SIZE;i++)
{
for(int j=0;j<BOARD_SIZE;j++)
{
System.out.print(board[i][j]);
}
System.out.print("\n");
}
}
public static void main(String[] args) throws Exception
{
Gobang bg=new Gobang();
bg.initBoard();
bg.printBoard();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inputstr=null;
while((inputstr=br.readLine())!=null)
{
String[] possStrArr=InputEvent.split(",");
int xPos=Integer.parseInt(posStrArr[0]);
int yPos=Integer.parseInt(posStrArr[1]);
bg.board[yPos-1][xPos-1]="●";
bg.printBoard();
System.out.println("请乱来,应格式为:");
}
}
}
其实是李刚的疯狂JAVA讲义上的简易五子棋,但是课本没有import任何包,我加了两个,但是还有问题