1、Java 小游戏第一个Java 文件:import java.util.Scanner;public class GameA_B public static void main(String args) Scanner reader=new Scanner(System.in); int area;System.out.println(“Game StartPlease enter the area:(1-9)“ +n+“1,2,3 means easy“+n+“4,5,6 means middle“+n+“7,8,9 means hard“+n+“Please choose:“);area=
2、reader.nextInt();switch(area-1)/3)case 0:System.out.println(“You choose easy! “);break;case 1:System.out.println(“You choose middle! “);break;case 2:System.out.println(“You choose hard! “);break;System.out.println(“Good Luck!“);GameProcess game1=new GameProcess(area);game1.process();第二个 Java 文件:impo
3、rt java.util.Random;import java.util.Scanner;public class GameProcess int area,i,arrcount,right,midright,t;int base=new intarrcount,userNum=new intarea,sysNum=new intarea;Random random=new Random();Scanner reader=new Scanner(System.in);GameProcess(int a)area=a;arrcount=10;right=0;midright=0;t=0;base
4、=new intarrcount;userNum=new intarea;sysNum=new intarea;for(int i=0;iarrcount;i+)basei=i;/System.out.println(basei);void process()rand();while(right!=area)scanf();compare();print();check();void rand()for(i=0;iarea;i+)t=random.nextInt(arrcount);/System.out.println(t);sysNumi=baset;System.out.println(
5、baset);delarr(t);void delarr(int t)for(int j=t;jarrcount-1;j+)basej=basej+1;arrcount-;void scanf()System.out.println(“The system number has created!“+“n“+“Please enter “+area+“ Numbers“);for(int i=0;iarea;i+)userNumi=reader.nextShort();void check()if(right=area)System.out.println(“You win!“ );boolean check(int i)return true;void compare()int i=0,j=0;right=midright=0;for(i=0;iarea;i+)for(j=0;jarea;j+)if(userNumi=sysNumj)if(i=j)right+;elsemidright+;void print()System.out.println(“ A “+right+“ B “+midright);