Commit 41f98482 by BellCodeEditor

save project

parent ce66f2ed
Showing with 11 additions and 4 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level=1000 self.level=1
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade():
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase=Hero('亚瑟',300,20) yase=Hero('亚瑟',300,20)
print('亚瑟的初血:',yase.hp)
print('亚瑟升级的血:',yase.hp)
houyi=Hero('后羿',300,20) houyi=Hero('后羿',300,20)
print('亚瑟的血:',yase.hp) print('亚瑟的初血:',houyi.hp)
print('后羿的血:',houyi.hp) print('后羿升级的血:',houyi.hp)
\ No newline at end of file \ 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