【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《java小游戏源代码》,欢迎阅读!
Java小游戏
第一个Java文件:
import class GameA_B {
public static void main(String[] args) { Scanner reader=new Scanner; int area;
"Game Start…………Please 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=();
switch((area-1)/3) {
case 0:"You choose easy! ");break; case 1:"You choose middle! ");break; case 2:"You choose hard! ");break; }
"Good Luck!");
GameProcess game1=new GameProcess(area); (); }
第二个Java文件:
import class GameProcess {
int area,i,arrcount,right,midright,t;
int base[]=new int[arrcount],userNum[]=new int[area],sysNum[]=new Random random=new Random(); GameProcess(int a) {
area=a; arrcount=10; right=0; midright=0; t=0;
base=new int[arrcount]; userNum=new int[area]; sysNum=new int[area]; for(int i=0;i<arrcount;i++) {
base[i]=i; //
}
}
int[area];
Scanner reader=new Scanner;
}
void process() { rand();
while(right!=area) {
scanf(); compare(); print(); check(); } }
void rand() {
for(i=0;i<area;i++) { } }
void delarr(int t) {
for(int j=t;j<arrcount-1;j++) }
void scanf() {
"The system number has created!"+"\n"+"Please enter "+area+" Numbers");
for(int i=0;i<area;i++) {
userNum[i]=(); } }
void check() {
if(right==area) "You win…………!"); }
boolean check(int i) {
return true;
base[j]=base[j+1];
arrcount--;
t=(arrcount); //
sysNum[i]=base[t]; delarr(t);
}
void compare() {
int i=0,j=0; right=midright=0; for(i=0;i<area;i++) { } }
void print() {
" A "+right+" B "+midright); } }
for(j=0;j<area;j++) {
if(userNum[i]==sysNum[j]) { } }
if(i==j) right++; else
midright++;
本文来源:https://www.wddqxz.cn/d33a7b26bc23482fb4daa58da0116c175e0e1e0f.html