Commit 34a5535b by BellCodeEditor

save project

parent 8d732d5f
Showing with 14 additions and 7 deletions
class hero: class hero:
def __init__(self,name): def __init__(self,name):
self.level=1 self.level=1
self.hp=999990 self.hp=240
self.attack=99999999999999999999 self.attack=50
self.name=name self.name=name
def combat(self,enemy): def combat(self,enemy):
enemy.hp-=self.attack enemy.hp-=self.attack
...@@ -14,7 +14,14 @@ class hero: ...@@ -14,7 +14,14 @@ class hero:
info3 = enemy.name+'还剩下'+str(enemy.hp)+'点生命值' info3 = enemy.name+'还剩下'+str(enemy.hp)+'点生命值'
print(info1+info2+info3) print(info1+info2+info3)
class player(hero):
ys=hero("亚瑟") def __init__(self,name):
hy=hero("后羿") super().__init__(name)
ys.combat(hy) self.hp=200
\ No newline at end of file self.attack=70
Player = player("后羿")
print("玩家攻击力为",player.attack)
print("玩家血量为",player.hy)
#ys=hero("亚瑟")
#hy=hero("后羿")
#ys.combat(hy)
\ 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