Commit 8be35163 by BellCodeEditor

save project

parent 2bd06260
Showing with 32 additions and 14 deletions
...@@ -4,19 +4,36 @@ class Hero: ...@@ -4,19 +4,36 @@ class Hero:
self.name = name self.name = name
self.hp= hp self.hp= hp
self.attack= attack self.attack= attack
yase = Hero("亚瑟",99999999998,99999998) # yase = Hero("亚瑟",99999999998,99999998)
kunkun = Hero("坤坤",99999999998,99999998) # kunkun = Hero("坤坤",99999999998,99999998)
print("亚瑟的血量:",yase.hp) # print("亚瑟的血量:",yase.hp)
print("坤坤的血量:",kunkun.hp) # print("坤坤的血量:",kunkun.hp)
def upgrade(): # def upgrade():
yase.level=yase.level+1 # yase.level=yase.level+1
yase.hp=yase.hp+1 # yase.hp=yase.hp+1
yase.attack=yase.attack+1 # yase.attack=yase.attack+1
yase = hero("亚瑟",99999999999,99999999) # yase = hero("亚瑟",99999999999,99999999)
print("亚瑟的初始血量:",yase.hp) # print("亚瑟的初始血量:",yase.hp)
upgrade() # upgrade()
upgrade() # upgrade()
print("升级两次后,yase的血量为:",yase.hp) # print("升级两次后,yase的血量为:",yase.hp)
def upgrade(self):
self.level=self.level+1
self.hp = self.hp + 1
self.attack = self.attack + 1
houyi = Hero("坤坤",99999999999999999999999999,9999999999999999999999999999999999)
houyi.upgrade()
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