Commit 60fc38c6 by BellCodeEditor

save project

parent 8070a868
Showing with 11 additions and 2 deletions
...@@ -4,7 +4,16 @@ class Hero: ...@@ -4,7 +4,16 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgarde(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase=Hero('亚瑟',300,20) yase=Hero('亚瑟',300,20)
houyi=Hero('后羿',250,23) houyi=Hero('后羿',250,23)
print('亚瑟的恤量',yase.hp) #print('亚瑟的血量',yase.hp)
print('后羿的攻击力',houyi.hp) #print('后羿的攻击力',houyi.hp)
houyi.upgarde()
print('后羿的等级',houyi.level)
print('后羿的血量',houyi.hp)
print('后羿的攻击力',houyi.attack)
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