Commit 6717ad24 by BellCodeEditor

save project

parent 0d89cdfc
Showing with 15 additions and 19 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self, name, hp, attack):
self.level=1 self.level = 1
self.name=name self.name = name # name:名字
self.hp=hp self.hp= hp
self.acttack=acttack self.attack= attack # attack:攻击
yese=Hero("yase",300,20) def upgrade(self):
hy=Hero("hy",250,23) self.level+=1
k=Hero("K",5600,199) self.hp+=50
print(yese.acttack) self.attack+=4
print(hy.acttack) houyi=Hero("后羿",250,25)
print(k.acttack) houyi.upgrade()
def upgrade(): print("等级为:",houyi.level)
yese.level+=1 print("血量为:",houyi.hp)
yese.hp+=50 print("攻击力为:",houyi.attack)
yese.acttack+=10 \ No newline at end of file
upgrade()
upgrade()
print(yese.acttack)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment