Commit 55cf3901 by BellCodeEditor

save project

parent a8e7378f
Showing with 8 additions and 8 deletions
# 英雄角色类 # 英雄角色类
class Hero(): class Hero():
def __init__(self, name): def __init__(self,name):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
...@@ -18,13 +18,13 @@ class Hero(): ...@@ -18,13 +18,13 @@ class Hero():
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
class Player(Hero): class Player(Hero):
def __init__(self, name): def __init__(self,name):
super().__init__(self.name) super().__init__(name)
self.hp = 100 self.hp = 100
self.attack = 400 self.attack = 400
player = Player("后羿") player = Player("后羿")
computer = Hero("亚瑟") computer = Hero("亚瑟")
print("玩家的血量为:",Player.hp) print("玩家的血量为:",player.hp)
print("玩家的等级为:",Player.level) print("玩家的等级为:",player.level)
print("玩家的攻击力为:",Player.attack) print("玩家的攻击力为:",player.attack)
print("玩家的名称为:",Player.name) print("玩家的名称为:",player.name)
\ 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