印刷游戏

第一个Java文件:导入Java . util . scanner;公共类GameA_B {

公共静态void main(String[] args) {

扫描仪阅读器=新扫描仪(system . in);

int区域;

System.out.println("游戏开始…………请输入区域:(1-9)" + '\n'+"1,2,3表示容易"+'\n'+"4,5,6表示中间"+'\n'+ "7,8,9表示难"+ '\n'+"请选择:");

area = reader . nextint();

开关((area1)/3) {

案例0:System.out.println("你选容易!");打破;

case 1:System.out.println("你选中间!");打破;案例二:System.out.println("你选硬的!");打破;} System.out.println("祝你好运!");game process game 1 = new game process(area);game 1 . process();}}第二个Java文件:导入Java . util . random;导入Java . util . scanner;公共类GameProcess { int area,I,arrcount,right,midright,t;int base[]=new int[arrcount],userNum[]=new int[area],sysNum[]= new int[area];Random Random = new Random();扫描仪阅读器=新扫描仪(system . in);game process(int a){ area = a;arr count = 10;右= 0;midright = 0;t = 0;base = new int[arr count];userNum = new int[area];sys num = new int[area];for(int I = 0;我& ltarrcounti++){ base[I]= I;//system . out . println(base[I]);} } void process(){ rand();而(对!= area){ scanf();compare();print();check();} } void rand(){ for(I = 0;我& lt面积;i++){ t = random . nextint(arr count);//system . out . println(t);sys num[I]= base[t];system . out . println(base[t]);delarr(t);} } void delarr(int t){ for(int j = t;j & ltarr count-1;j++)base[j]= base[j+1];arr count-;} void scanf(){ system . out . println("系统号已创建!"+"\n"+"请输入"+区域+"数字));for(int I = 0;我& lt面积;i++){ userNum[I]= reader . next short();} } void check(){ if(right = = area)system . out . println("你赢了…………!");}布尔校验(int i) {返回true} void compare() { int i=0,j = 0;右=中右= 0;for(I = 0;我& lt面积;i++){ for(j = 0;j & lt面积;j++){ if(userNum[I]= = sysNum[j]){ if(I = = j)right++;else mid right++;} } } } void print(){ system . out . println(" A "+right+" B "+midright);} }

自己慢慢分吧!!!!!!!