Commit 9dc659ac by BellCodeEditor

save project

parent ce44dbd8
Showing with 47 additions and 4 deletions
class Dog():
def __init__(self):
self.foot =4#腿
self.color ="white"
class Husky(Dog):
def run(self):
print("狗狗正在快速的跑")
class wangcai(Husky):
pass
wangcai=wangcai()
wangcai.run()
...@@ -22,11 +22,19 @@ class Hero: # 英雄类 ...@@ -22,11 +22,19 @@ class Hero: # 英雄类
exit() exit()
class Player(): # 玩家英雄 class Player(Hero): # 玩家英雄
def __init__(self,name): def __init__(self,name,hero_type):
??? super().__init__(name)
self.hp=200
self.attack=50
self.hero_type=hero_type
print(self.name,"创建成功,英雄的类型是",self.hero_type)
print("当前的等级,攻击力,血量是",self.level,self.attack,self.hp)
player = Player("后羿") player = Player("后羿","射手")
print("玩家的血量值为:",player.hp) print("玩家的血量值为:",player.hp)
print("玩家的攻击力为:",player.attack) print("玩家的攻击力为:",player.attack)
class Cat():
def __init__(self):
self.eye = 2
self.foot = 4
self.color= "black"
def eat(self):
print("今天吃了xxx")
cjza=Cat()
cjza.eat()
class Animal():
def __init__(self):
self.foot = 4 # 腿
self.color ="white"
self.weight = "19kg"
class Bird(Animal):
def __init__(self):
super().__init__()
self.foot = 2
self.weight ="8kg"
niao=Bird()
print(niao.foot,niao.weight)
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