题目:随机生成玩家1和玩家2的生命值(100,150)以及玩家1和玩家2的攻击值(30,50),然后互相攻击,直至一方生命值小于零,战斗结束;这样的战斗持续三局,采取三局两胜,最后输出战斗结果,公布获胜方。并询问是否再玩一盘?
import java.util.Scanner;
public class Exer0905 {
public static void main(String[] args) {
boolean isFlag = true;
while(isFlag == true) {
int playerWinTime1 = 0;
int playerWinTime2 = 0;
for (int i = 1; i < 4; i++) {
int blood1 = (int) (Math.random() * (149 - 100) + 99);
int blood2 = (int) (Math.random() * (149 - 100) + 99);
int attack1 = (int) (Math.random() * (49 - 30) + 29);
int attack2 = (int) (Math.random() * (49 - 30) + 29);
System.out.println("————————————————现在是第" + i + "局————————————————");
System.out.println("【玩家1】");
System.out.println("血量:" + blood1);
System.out.println("攻击:" + attack1);
System.out.println("--------------------------------------------");
System.out.println("【玩家2】");
System.out.println("血量:" + blood2);
System.out.println("攻击:" + attack2);
System.out.println("-