Commit 7dd0e6b3 by BellCodeEditor

save project

parent 26d5fa9a
Showing with 9 additions and 10 deletions
...@@ -4,6 +4,13 @@ class Hero: ...@@ -4,6 +4,13 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade():
self.level+=1
self.hp+=300
self.attack+=50
yase=Hero("亚瑟",300,20) yase=Hero("亚瑟",300,20)
houyi=Hero("后羿",250,23) houyi=Hero("后羿",250,23)
print("姓名:",yase.name) print("姓名:",yase.name)
...@@ -11,14 +18,6 @@ print("血量:",yase.hp) ...@@ -11,14 +18,6 @@ print("血量:",yase.hp)
print("攻击力:",yase.attack) print("攻击力:",yase.attack)
print("姓名:",houyi.name) print("姓名:",houyi.name)
print("血量:",houyi.hp) print("血量:",houyi.hp)
print("攻击力:",houyi..attack)
def upgrade():
yase.level+=1
yase.hp+=300
yase.attack+=50
houyi.level+=1
houyi.hp+=300
houyi.attack+=50
upgrade() upgrade()
upgrade() upgrade()
print("攻击力:",yase.hp) print("攻击力:",self.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