Commit 07fd3671 by BellCodeEditor

save project

parent c1c5b943
Showing with 23 additions and 2 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+5
wdw Houyi=Hero("后羿",240,25)
\ No newline at end of file print("后羿的初始血量是:",Houyi.hp)
print("后羿的初始等级是:",Houyi.level)
print("后羿的初始攻击是:",Houyi.attack)
Houyi.upgrade()
Houyi.upgrade()
print("*"*50)
print("升级两次后后羿的等级是",Houyi.level)
print("升级两次后后羿的血量是",Houyi.hp)
print("升级两次后后羿的攻击是",Houyi.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