欢迎来到天天文库
浏览记录
ID:37845390
大小:48.50 KB
页数:16页
时间:2019-06-01
《java小游戏源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java小游戏第一个Java文件:importjava.util.Scanner;publicclassGameA_B{publicstaticvoidmain(String[]args){Scannerreader=newScanner(System.in);intarea;System.out.println("GameStart…………Pleaseenterthearea:(1-9)"+''+"1,2,3meanseasy"+''+"4,5,6meansmiddle"+''+"7,8,9meanshard"+''+"Pleasech
2、oose:");area=reader.nextInt();switch((area-1)/3){case0:System.out.println("Youchooseeasy!");break;case1:System.out.println("Youchoosemiddle!");break;case2:System.out.println("Youchoosehard!");break;}System.out.println("GoodLuck!");GameProcessgame1=newGameProcess(area);game1.proce
3、ss();}}第二个Java文件:importjava.util.Random;importjava.util.Scanner;publicclassGameProcess{intarea,i,arrcount,right,midright,t;intbase[]=newint[arrcount],userNum[]=newint[area],sysNum[]=newint[area];Randomrandom=newRandom();Scannerreader=newScanner(System.in);GameProcess(inta){area=a
4、;arrcount=10;right=0;midright=0;t=0;base=newint[arrcount];userNum=newint[area];sysNum=newint[area];for(inti=0;i5、dom.nextInt(arrcount);//System.out.println(t);sysNum[i]=base[t];System.out.println(base[t]);delarr(t);}}voiddelarr(intt){for(intj=t;j6、ti=0;i7、;}}}}voidprint(){System.out.println("A"+right+"B"+midright);}}importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classTestGame{publicstaticvoidmain(String[]args){Appap=newApp();//调用App()开始运行程序ap.show();}}classAppextendsJFrame{MainPanelmp;publicApp(){mp=newMainPanel();thi8、s.getContentPane().add(mp);this.setSize(
5、dom.nextInt(arrcount);//System.out.println(t);sysNum[i]=base[t];System.out.println(base[t]);delarr(t);}}voiddelarr(intt){for(intj=t;j6、ti=0;i7、;}}}}voidprint(){System.out.println("A"+right+"B"+midright);}}importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classTestGame{publicstaticvoidmain(String[]args){Appap=newApp();//调用App()开始运行程序ap.show();}}classAppextendsJFrame{MainPanelmp;publicApp(){mp=newMainPanel();thi8、s.getContentPane().add(mp);this.setSize(
6、ti=0;i
7、;}}}}voidprint(){System.out.println("A"+right+"B"+midright);}}importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classTestGame{publicstaticvoidmain(String[]args){Appap=newApp();//调用App()开始运行程序ap.show();}}classAppextendsJFrame{MainPanelmp;publicApp(){mp=newMainPanel();thi
8、s.getContentPane().add(mp);this.setSize(
此文档下载收益归作者所有