Commit c94ac92e by BellCodeEditor

save project

parent 1cf9f5c8
Showing with 29 additions and 8 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, prey):
print("小猫抓住了"+prey)
role = Cat()
role.run()
role.skill("老鼠")
\ No newline at end of file
class Dog: # 狗类 class Dog: # 狗类
def __init__(self): def __init__(self,name):
self.name=name
self.footNum = 4 # 腿 self.footNum = 4 # 腿
self.eyeNum = 2 # 眼睛 self.eyeNum = 2 # 眼睛
self.head = 1 # 头 self.head = 1 # 头
...@@ -7,12 +8,15 @@ class Dog: # 狗类 ...@@ -7,12 +8,15 @@ class Dog: # 狗类
self.skin = "white" self.skin = "white"
def run(self): def run(self):
print("狗狗飞快的跑起来") print(self.name+"飞快地跑起来")
class Husky(Dog): # 哈士奇类 class Husky(Dog): # 哈士奇类
def __init__(self): def __init__(self,name):
?? super().__init__(name)
self.skin='black'
coco = Husky() print('你有一只'+self.skin+'的'+self.name)
print(coco.skin) print(self.name+"飞快地躲起来")
\ No newline at end of file xixi=Dog(input('你养了一只'))
xixi.run()
coco = Husky(input('他养的是'))
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