Commit 3ed9ff42 by BellCodeEditor

auto save

parent 9a581ef4
Showing with 31 additions and 3 deletions
class Dog:
def __init__(self,color):
self.tui = 4 # 腿 这个实例的属性
self.er = 2 # 耳
self.yan = 2 # 眼
self.color = color
huang = Dog("黑色")
print(huang.color,huang.tui)
class Dog:
def __init__(self,color,price):
self.tui = 4 # 腿
self.er = 2 # 耳
self.yan = 2 # 眼
self.color = color
self.price = price
dog1 = Dog("黑色",100.0)
print(dog1.color,dog1.price)
...@@ -6,9 +6,13 @@ class Hero(object): ...@@ -6,9 +6,13 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,beigongji): # 攻击
??? beigongji.hp = beigongji.hp - self.attack
info1 = ? #攻击与被攻击者
info2 = ? # 攻击力造成的伤害!
info3 = ? # 剩余血量
info = info1+info2+info3 # 将上面3段字符串拼接成一段语句输出!
print(info1)
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) yase.combat(houyi)
\ 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