代码拉取完成,页面将自动刷新
import java.util.*;
public class Player
{
private int strength = 100;
private static Map<String, Thing> bag = new HashMap<>();
public void step() {
strength -= 10;
}
public void pick(Thing thing) {
bag.put(thing.getName(), thing);
System.out.println("捡到了:"+thing.getName()+"能量:"+thing.getEnergy());
}
public void eat(String name) {
Thing thing = bag.get(name);
if(thing != null) {
int strengthnow=strength;
strength += thing.getEnergy();
if(strength >100) {
strength = 100;
}
System.out.println("吃掉了"+name+"恢复"+(strength-strengthnow)+"能量");
System.out.println("现在:"+strength);
bag.keySet().removeIf(key -> key.contains(name));
}
}
public void checkBag() {
bag.keySet().stream().forEach(key -> System.out.print(key + " "));
System.out.println();
}
public boolean isDead() {
return strength <= 0;
}
public void monster(int hurt) {
strength = strength - hurt;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。