Commit 854963dd by BellCodeEditor

save project

parent 1a10b3e9
class Hero:
def __init__(self,name,hp,attack):
self.level = 3
self.name = name
self.hp = hp
self.attack = attack
def upgrate(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
# libai = Hero("李白",20,18)
# kai = Hero("凯",30,19)
# print("凯的血量为:",kai.hp)
# print("李白的攻击力为:",libai.attack)
# def upgrate(self):
# self.level=self.level+1
# self.hp=self.hp+50
# self.attack=self.attack+4
libai = Hero("李白",20,18)
print("李白的攻击力为:",libai.attack)
libai.upgrate()
# upgrate(self)
print("升级一次后,李白的攻击力为:",libai.attack)
\ 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