public void createPlayer(){
System.out.println("------------------创建玩家---------------------");
int id;
for(int i=0;i<2;i++){
System.out.println("请输入第"+(i+1)+"位玩家ID和姓名");
Scanner console=new Scanner(System.in);
while(true){
boolean isInt=true;
try{
System.out.println("输入ID:");
id=console.nextInt();
players[i].setId(id);
}catch(Exception e){
isInt=false;
System.out.println("输入类型不匹配,请输入一个整数型ID!!!");
String clear=console.next();
}
if(isInt)
break;
}
System.out.println("输入姓名:");
String name=console.next();
players[i].setName(name);
}
for(int j=0;j<2;j++){
System.out.println("---欢迎玩家:"+players[j].getName());
}
}