展开全部
int playerHp = 50;
e69da5e6ba9062616964757a686964616f31333337383337int monsterHp = 50;
String ak = "a";
String mk = "b";
System.out.println("--------GREAM UP----------");
System.out.println("输入a;b,a为攻击b为回血");
Scanner input = new Scanner(System.in);String i = input.next();
while (playerHp > 0 && monsterHp > 0) {if (i.equals(ak)) {
int playerAtk = new Random().nextInt(10) + 1;
System.out.println("人类对怪物造成了" + playerAtk);
int monsterAtk = new Random().nextInt(10) + 1;
System.out.println("怪物对人类造成了" + monsterAtk);
monsterHp = monsterHp - playerAtk;
if (monsterHp > 0) {
playerHp = playerHp - monsterAtk; // Integer(a[1])).equals(b[1]));
}} else if (i.equals(mk)) {
int playerAtk = new Random().nextInt(10) + 1;
System.out.println("人类回复了" + playerAtk);
int monsterAtk = new Random().nextInt(10) + 1;
System.out.println("怪物回复了" + monsterAtk);
}
}
注意打了点的行