package com
;
import java
.util
.Random
;
public class Wusongdahu {
public static void main(String
[] args
) {
wusong wu
= new wusong();
laohu hu
= new laohu();
int i
= 1;
while(wu
.hp
>0&&hu
.hp
> 0){
System
.out
.println("第"+i
+"回合");
i
++;
int wu_sh
= wu
.daHU();
hu
.hp
= hu
.hp
- wu_sh
;
if(hu
.hp
< 0) {
hu
.hp
= 0;
}
System
.out
.println("老虎剩余生命值:" + hu
.hp
);
int hu_sh
= hu
.daRen();
wu
.hp
= wu
.hp
- hu_sh
;
if(wu
.hp
< 0) {
wu
.hp
= 0;
}
System
.out
.print("武松剩余生命值:" + wu
.hp
);
System
.out
.println("\n");
}if(wu
.hp
== 0&&hu
.hp
==0 ) {
System
.out
.println();
System
.out
.println("两人势均力敌,两败俱伤,不久都是死在破伤风。默哀");
}else if(wu
.hp
<=0){
System
.out
.println("老虎赢得胜利");
}else {
System
.out
.println("武松赢得胜利");
}
}
}
class wusong{
int hp
=200;
String jiNen
[] = {"脚踹","手锤","头撞"};
int shangHai
[] = {10,30,40};
String
[]leixing
= {"普通","猛击","智力"};
int daHU(){
int arr
= new Random().nextInt(3);
String jN
= jiNen
[arr
];
int sH
= shangHai
[arr
];
String lX
= leixing
[arr
];
System
.out
.print("武松使用: "+jN
+"\t攻击老虎,造成" + sH
+ "点: "+lX
+"伤害,");
return sH
;
}
}
class laohu{
int hp
= 300;
String jiNen
[] = {"撕咬","抓","扫"};
int shangHai
[] = {30,20,10};
String
[]leixing
= {"掉肉","流血","普通"};
int daRen(){
int arr
= new Random().nextInt(3);
String jN
= jiNen
[arr
];
int sH
= shangHai
[arr
];
String lX
= leixing
[arr
];
System
.out
.print("老虎使用: "+jN
+"\t攻击武松,造成"+ sH
+"点: "+lX
+"伤害,");
return sH
;
}
}
转载请注明原文地址: https://mac.8miu.com/read-497547.html