Commit e5f788fe by BellCodeEditor

save project

parent 26a05f88
Showing with 16 additions and 4 deletions
class hero: class Hero:
def __init__(self): def __init__(self,name,hp,attack):
self.level=1 self.level=1
self.hp=300 self.name=name
self.attack=2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 self.hp=hp
self.attack=attack
def upgrade(self):
self.hp=self.hp+50
self.level=self.level+1
self.attack=self.attack+4
yase=Hero('亚瑟',300,20)
hoyi=Hero('后羿',240,25)
yase.upgrade()
yase.upgrade()
hoyi.upgrade()
print('后羿攻击为:',hoyi.attack)
print('亚瑟生命为:',yase.hp)
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