,在之前的学习过程中觉得最有意思的还是写小游戏的过程,非常的锻炼逻辑思维也把这段代码分享一下:public class Person {
int HP=100;
int attack=60;
int medicine=0;
int defend=20;
int distance=0;
//int[] arr={attack,medicine,defend};
public void show(){
System.out.println("血量:"+HP+"; 攻击力:"+attack+"; 急救包:"+medicine+"; 防御:"+defend);
}
public void search(){
int[] arr=new int[4];
Random r=new Random();
for(int i=0;i<4;i++){
int a=r.nextInt(2);
arr[i]=a;
//捡东西选择且枪只能捡到一次,通过攻击力控制
if(a==1&&i==1&&attack!=90){
int b=r.nextInt(4);
switch(b){
case 1:
System.out.println("捡到一把M4");
break;
case 2:
System.out.println("捡到一把AK");
break;
case 3:
System.out.println("捡到一把98K");
break;
default:
System.out.println("捡到一把uzi");
break;
}
attack+=30;