Commit 6a8166fc by BellCodeEditor

save project

parent f9e0b10a
Showing with 6 additions and 7 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1
self.hp = 3500
self.attack = 388
self.name = name
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
enemy.hp -= self.attack enemy.hp -= self.attack
...@@ -18,5 +15,7 @@ class Hero(object): ...@@ -18,5 +15,7 @@ class Hero(object):
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") yase.combat(houyi)
yase.combat(houyi) class p(Hero):
\ No newline at end of file def _init(self,name):
\ 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