加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Player.java 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
马晨阳 提交于 2021-06-21 08:49 . 0
import java.util.*;
public class Player
{
private int strength = 100;
private int health = 100;
private int aggressivity=5;
private static Map<String, Thing> bag = new HashMap<>();
//public void step() {
//strength -= 10;
//}
public void sethealth(int hurt)
{
this.health+=hurt;
}
public int gethealth(){
return this.health;
}
public int getaggressivity(){
return this.aggressivity;
}
public void pick(Thing thing) {
bag.put(thing.getName(), thing);
System.out.println("捡到了:"+"["+thing.getName()+"]");
}
public void eat(String name) {
Thing thing = bag.get(name);
if(thing != null) {
int strengthago=strength;
bag.keySet().removeIf(key -> key.contains(name));
health +=30;
aggressivity +=8;
System.out.println("使用了"+name+" "+"五条悟 他悟了");
System.out.println("生命值加30,攻击力加8");
System.out.println("生命值:"+health+"攻击力:"+aggressivity);
}
}
public void checkBag() {
bag.keySet().stream().forEach(key -> System.out.print(key + " "));
System.out.println();
}
public boolean isDead() {
return strength <= 0;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化