Commit 42f15ad0 by BellCodeEditor

save project

parent 1a34df6b
Showing with 30 additions and 23 deletions
class Dog: # 狗类
def __init__(self):
self.footNum = 4 # 腿
self.eyeNum = 2 # 眼睛
self.head = 1 # 头
self.earsNum = 2 # 耳朵
self.skin = "white"
# 英雄角色类
class Hero(object):
def __init__(self, name,a,b,da,db):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
self.a = a
self.da = da
self.b = b
self.db = db
def combat(self,en): # 攻击
en.hp-=self.attack
print(self.name,"lv:"+str(self.level),"at:"+str(self.attack),"hp:"+str(self.hp))
at="普通攻击"
print("-"*30)
print(self.name,"对",en.name,"使用了"+at,"\n造成了"+str(self.attack)+"点伤害")
print("对方还剩",en.hp,"点血")
if self.hp < 1:
print("您已阵亡")
exit()
elif en.hp < 1:
print("对方已阵亡")
exit()
print("-"*30)
def run(self):
print("狗狗飞快的跑起来")
class Husky(Dog): # 哈士奇类
def __init__(self):
super().__init__()
self.footNum = 2 # 腿
self.eyeNum = 2 # 眼睛
self.head = 1 # 头
self.earsNum = 2 # 耳朵
self.skin = "black and white"
coco = Husky()
ococ = Dog()
print(coco.footNum,"\n",ococ.footNum)
\ No newline at end of file
yase = Hero("伏拉夫","吃火锅",100,"吃小孩",105)
houyi= Hero("蔡徐坤","鸡你太美",115,"打篮球",75)
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