2020年java小游戏源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

System. out .println(
"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:"
{
t =random .nextInt(
arrcount );
//System.out.println(t);
sysNum [ i ]= base [ t ];
System. out .println(
base [ t ]);
delarr( t );
}
}
void delarr( int t)
{
f or ( int j=t;j< arrcount -1;j++)
{ base [i]=i; //System.out.println(base[i]);
} }
void process()
{
r and();
while ( right != area ) {
s canf();
c ompare();
p rint();
c heck();
}
}
void rand()
{
f or ( i =0; i < area ; i ++)
} }
}
void print() {
System. out .println( }
" A " + right + " B " + midright );
}
int [ area ];
Random random = new Random();
Scanner
reader =new Scanner(System.
in );
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++)
}
}
第二个 Java 文件: import java.util.Random; import java.util.Scanner;
public class GameProcess { int area , i , arrcount , right , midright , t ;
int base []= new int [ arrcount ], userNum []= new int [ area ], sysNum []= new
+ "\n" + "Please
{ userNum [i]=
}
reader
.nextShort();
}
void check()
{ if ( right == area )
System. }
boolean
out .println( check( int
"You win …………!" ); i)Βιβλιοθήκη { r eturn);
a rea=reader.nextInt();
s witch ((area-1)/3) {
c ase 0:System. out .println(
"You choose easy! "
); break ;
c ase 1:System. out .println(
"You choose middle! "
); break ;
c ase 2:System. out .println(
"You choose hard! "
); break ;
}
System. out .println( GameProcess game1=
"Good Luck!" ); new GameProcess(area);
game1.process();
第一个 Java 文件: import java.util.Scanner;
Java 小游戏
public class GameA_B {
public static void main(String[] args) {
Scanner reader=
new Scanner(System.
in );
int area;
true ;
}
void compare()
{
i nt i=0,j=0; r ight = midright =0;
f or (i=0;i< area ;i++)
{ for (j=0;j< area ;j++)
{
if ( userNum [i]== sysNum [j]) {
if (i==j)
right ++; else midright ++; }
base [j]= base [j+1];
arrcount --;
}
void scanf()
{
System. out .println(
"The system number has created!"
enter " + area + " Numbers" );
for ( int i=0;i< area ;i++)
相关文档
最新文档