Commit 194c0c89 by BellCodeEditor

auto save

parent 8e5cfffc
Showing with 12 additions and 4 deletions
......@@ -7,10 +7,18 @@ class Hero:
self.name=name
self.hp=hp
self.attack=attack
#定义一个升级功能的函数upgrade,让等级每升一级,血量加50,攻击力加4
def upgrade():
yase.level=yase.level+1
yase.hp+=50
yase.attack+=4
#实例对象yase,houyi
yase=Hero('亚瑟',300,20)
houyi=?
#打印yase的血量hp
upgrade()
upgrade()
#houyi=?
#打印yase的upgrade()血量hp
print('亚瑟的血量为:'+str(yase.hp))
#打印houyi的血量hp
print('后裔的血量为:'+str(houyi.hp))
\ No newline at end of file
#print('后裔的血量为:'+str(houyi.hp))
\ 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