奥特曼翻译代码
from random import randint # 导入randint函数
class Monster(object):
def __init__(self, name, energy):
self.name = name
= energy
>= 100:
print(self.name + "满血战斗")
else:print(self.name + "目前有" + ) + "的血量")
print("警告:" + self.name + "需要补血")
def eat(self, energy):
<= 100:
random翻译for i in range(10, 100, 10):
+= energy # 执行吃的语句,吃就+10,如果>100,就不吃了
print("正在补血.....")
print(self.name + "现在有" + ) + "的血量")
class Ultraman(object):
def __init__(self, name, alk):
self.name = name
self.alk = alk
return
def beat(self, other, c):
= - c * self.alk
<= 0:
print(self.name + "攻击" + other.name + str(c) + "次")
print("恭喜" + self.name + "成功打死" + other.name)
else:
print(self.name + "攻击" + other.name + str(c) + "次")
print("很遗憾" + self.name + "没有打死" + other.name)
M1 = Monster('月月', 10)
M1.eat(10)
U1 = Ultraman('水水', 999)
U1.beat(M1, 1)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论