package zonghelianxi; public class GameTest { public static void main(String[] args) { Role r1=new Role("1",100); Role r2=new Role("2",100); while (true){ r1.attack(r2); r2.attack(r1); if (r2.getBlood()==0){ System.out.println(r1.getName()+"ko"+r2.getName()); }else if (r1.getBlood()==0){ System.out.println(r2.getName()+"ko"+r1.getName()); } } } } class Role { private String name; private int blood; public Role(){}; public Role(String name,int blood){ this.name=name; this.blood=blood; } public void setName(String name){ this.name=name; } public String getName(){ return name; } public void setBlood(int blood){ this.blood=blood; } public int getBlood(){ return blood; } public void attack(Role role){ Random r=new Random(); int hurt=r.nextInt(20)+1; int reblood=role.getBlood()-hurt; reblood=reblood<0 ? 0:reblood; role.setBlood(reblood); System.out.println(this.getName()+"1攻击"+role.getName()+"2造成"+hurt+"伤害"+role.getName()+"还有"+reblood+"血"); } } 请帮我修改循环
时间: 2024-04-13 15:27:59 浏览: 111
C#中static void Main(string[] args) 参数示例详解
2.each { file2 ->
def relativePath = file2.absolutePath - folderPath2
def file1 = new File(folderPath1 + relativePath)
if (!file1.exists()) {
// 文件只在第二个文件夹中存在,输出该信息你想修改循环的目的是什么?请提供更多的细节,以便我能够帮助你进行修改。
阅读全文