import java.util.Scanner;
public class FiveChessGame {
private int temp;
private String[][] String1;//注意在这里不能定义为char型不然打印的数字
////////////////////////////
public FiveChessGame(){
System.out.println("please input the line number");
Scanner sc=new Scanner(System.in);
this.temp=sc.nextInt();
String1=new String[temp][temp];
for(int i=0;i for(int j=0;j String1[i][j]="*";//注意在这里不能定义为char型不然打印的数字
}
}
System.out.print('\t');
for(int i=0;i System.out.print(i);
System.out.print('\t');
}
System.out.println();
for(int i=0;i System.out.print(i);//注意在这里的格式不能写成System.out.print(i+'\t');不然从9打印
System.out.print('\t');
for(int j=0;j
System.out.print(String1[i][j]+'\t');
}
System.out.println();
}
}
////////////////////
public int getline(){
return this.temp;
}
///////////////////////
public String[][] getString(){
return this.String1;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.*;
public class FiveChessPlayers {
private String name;
public static FiveChessGame fcg=new FiveChessGame();
//////////////////////
public FiveChessPlayers(){//玩多少行的游戏
System.out.println("please input player's name");
Scanner sc=new Scanner(System.in);
this.name=sc.next();
}
///////////////////
public String getName(){
return this.name;
}
////////////////////////////////
public void play(String str2){//the player could play the chess
Scanner sc=new Scanner(System.in);
int x,y;
while(true){
System.out.println("please input your chess");
x=sc.nextInt();
y=sc.nextInt();
if(x>=fcg.getline()||y>=fcg.getline()) {
System.out.println("your input is error");
continue;
}
if(fcg.getString()[x][y]=="*"){
fcg.getString()[x][y]=str2;
break;
}else{
System.out.println("you coudl'n put your chess here");
continue;
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.*;
public class TestChess {
private FiveChessPlayers f2;
private FiveChessPlayers f3;
public TestChess(){
f2=new FiveChessPlayers();
f3=new FiveChessPlayers();
}
///////////////////////////////////////////////////////////////////////////
public void display(){
System.out.print('\t');
for(int i=0;i System.out.print(i);
System.out.print('\t');
}
System.out.println();
for(int i=0;i System.out.print(i);//注意在这里的格式不能写成System.out.print(i+'\t');不然从9打印
System.out.print('\t');
for(int j=0;j System.out.print(FiveChessPlayers.fcg.getString()[i][j]+'\t');
}
System.out.println();
}
}
//////////////////////////////////////////////////////////////////////////////
public void putChess(String tem1){
if(tem1.equals("@"))
{
f2.play("@");
}
if(tem1.equals("#"))
{
f3.play("#");
}
}
///////////////////////////////////////////////////////