Commit 3fa11016 by BellCodeEditor

save project

parent 28eba965
Showing with 17 additions and 1483 deletions
class Cat:
def __init__(self):
self.footNum = 4 # 腿
self.eyeNum = 2 # 眼睛
self.head = 1 # 头
self.earsNum = 2 # 耳朵
self.skin = "black"
def run(self):
print("小猫飞快的跑起来")
def skill(self.zz):
print('小猫抓住了'+zz)
role = Cat()
role.skill("老鼠")
\ No newline at end of file
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp=200
self.attack = 388
self.name = name
def combat(self,enemy):
enemy.hp-=self.attack
infor1=self.name+'对'+enemy.name+'发起进攻,'
infor2='造成'+str(self.attack)+'点伤害,'
infor3=enemy.name+'还有'+str(enemy.hp)+'血量。'
if enemy.hp>0:
print(infor1+infor2+infor3)
else:
print(infor1+infor2+enemy.name+'噶了!')
exit()
yase=Hero('亚瑟')
houyi=Hero('后羿')
yase.combat(houyi)
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