Commit b8eb775c by BellCodeEditor

save project

parent eb0a1c7a
Showing with 12 additions and 1 deletions
...@@ -2,8 +2,12 @@ class Hero: ...@@ -2,8 +2,12 @@ class Hero:
def __init__(self,name): def __init__(self,name):
self.level = 1 self.level = 1
self.name =name self.name =name
self.hp =2500 self.hp =250
self.attack = 50 self.attack = 50
def combat(self,enemy):
class Plarer(Hero)
def combat(self,enemy): def combat(self,enemy):
enemy.hp-=self.attack enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+"发起攻击," info1=self.name+"对"+enemy.name+"发起攻击,"
...@@ -18,6 +22,10 @@ class Hero: ...@@ -18,6 +22,10 @@ class Hero:
print(info) print(info)
exit() exit()
class Plarer(Hero): class Plarer(Hero):
super()
class Plarer(Hero):
def __init__(self,name,hero_type): def __init__(self,name,hero_type):
super().__init__(name) super().__init__(name)
self.hp=200 self.hp=200
...@@ -28,3 +36,6 @@ class Plarer(Hero): ...@@ -28,3 +36,6 @@ class Plarer(Hero):
houyi=Plarer("后羿","射手") houyi=Plarer("后羿","射手")
yase=Hero("亚瑟") yase=Hero("亚瑟")
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