用户:可爱的小番茄查看:5 回复:5 评论:5 创建时间:2020-04-05T21:15:13
【作品展示】

【作品介绍】
很好玩的!
【作品源代码】
class Cat():
def __init__(self,name,color):
self.name=name
self.color=color
def cry(self):
print('喵喵喵~')
class SongCat(Cat):
def sing(self):
print('我会唱歌~')
class DanceCat(Cat):
def dance(self):
print('我会跳舞~')
class AICat(SongCat,DanceCat):
def __init__(self,name,color,info):
super().__init__(name,color)
self.info=info
lower_lvcha = Cat(name='低级_绿茶', color='灰色')
print(lower_lvcha.name)
print(lower_lvcha.color)
lower_lvcha.cry()
Song_intermediater_lvcha = SongCat(name='唱歌_中级_绿茶', color='灰色')
print(Song_intermediater_lvcha.name)
print(Song_intermediater_lvcha.color)
Song_intermediater_lvcha.cry()
Song_intermediater_lvcha.sing()
Dance_intermediater_lvcha = DanceCat(name='跳舞_中级_绿茶', color='灰色')
print(Dance_intermediater_lvcha.name)
print(Dance_intermediater_lvcha.color)
Dance_intermediater_lvcha.cry()
Dance_intermediater_lvcha.dance()
AI_lvcha = AICat(name='AI_绿茶', color='灰色', info='codemao')
print(AI_lvcha.name)
print(AI_lvcha.color)
print(AI_lvcha.info)
AI_lvcha.cry()
AI_lvcha.sing()
AI_lvcha.dance()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
蒟蒻OIer1048576import time
class Animal:
def __init__(self,Type,color):
self.Type=Type
self.color=color
class Cat(Animal):
def __init__(self,color):
super().__init__('CAT',color)
def miaow(self):
print('喵~')
class codemao(Cat):
def code(self,Type,Time):
print('喵~')
time.sleep(Time)
print('好啦!喵~')点赞0
评论
蒟蒻OIer1048576import time,threading,random
class Cat:
def __init__(self,Type,name):
self.Type = Type
self.name = name
self.hungryValue = 100
self.happyValue = 100
self.IQ = 50
def cry(self):
print('喵~呜~(伤心)')
def happy(self):
print('喵~(快乐)')
def hungry(self):
print('喵~咕噜噜~(饿了)')
def study(self):
print('喵~')
self.IQ+=5
def eat(self,food):
self.hungryValue += food*3
class SingCat(Cat):
def __init__(self, Type, name):
self.Type = Type
self.name = name
self.hungryValue = 100
self.happyValue = 100
self.IQ = 100
def sing(self):
print('啦啦啦')
evaluate = input('我唱的好不好啊?')
if evaluate == '好':
self.happyValue = min(100,happyValue+10)
self.happy()
elif evaluate == '不好':
print('喵~我可能还需要学习')
self.happyValue-=15
self.IQ+=10
class CodeMao(SingCat):
def __init__(self, Type, name):
self.Type = Type
self.name = name
self.hungryValue = 100
self.happyValue = 100
self.IQ = 200
def code(self,time):
for i in range(int(time)):
print('打代码ing')
time.sleep(1)
self.happyValue = min(100, happyValue+10)
self.happy()
self.IQ += 10
class AICodeMao(CodeMao):
def __init__(self, Type, name):
self.Type = Type
self.name = name
self.hungryValue = 100
self.happyValue = 100
self.IQ = 400
def SuperStudy(self,times):
for i in range(int(times)):
IQ+=0.01
time.sleep(0.005)
class Person:
def __init__(self):
self.food=0
self.Cat=Cat('可爱','喵喵')
def work(self):
print('今天,你赚了¥200,买了10袋喵粮')
self.food+=10
def see(person):
while person.Cat.happyValue >= 0 and person.Cat.hungryValue >= 0:
print('喵喵的饥饿值=', person.Cat.hungryValue)
print('喵喵的开心度=', person.Cat.happyValue)
print('喵喵的IQ=', person.Cat.IQ)
time.sleep(5)
def catset(person):
while person.Cat.happyValue >= 0 and person.Cat.hungryValue >= 0:
time.sleep(3)
person.Cat.happyValue -= 1
if person.Cat.happyValue <= 20:
person.Cat.cry()
if person.Cat.happyValue <0:
print('我这么伤心,你不来安慰我么?')
person.Cat.hungryValue -= 2
if person.Cat.hungryValue <= 20:
person.Cat.hungry()
if person.Cat.hungryValue < 0:
print('我这么饿!')
def main(person):
cls=1
while person.Cat.happyValue >= 0 and person.Cat.hungryValue >= 0:
a=input('请输入行为(1——玩耍)(2——学习)(3——喂食)(4——工作):')
if a == '1':
if cls>=1:
person.Cat.happy()
person.Cat.happyValue += 5
if cls>=2:
person.Cat.sing()
person.Cat.happyValue += 5
if cls>=3:
person.Cat.code(random.randint(1,5))
elif a == '2':
if cls == 4:
person.Cat.SuperStudy(random.randint(1, 5)*200)
else:
person.Cat.study()
elif a == '3':
person.Cat.eat(person.food)
elif a == '4':
time.sleep(3)
person.work()
if person.Cat.IQ >=400:
print('恭喜你,喵喵已升级为AI编程猫')
person.Cat = AICodeMao('可爱', '喵喵')
elif person.Cat.IQ >= 200:
print('恭喜你,喵喵已升级为编程猫')
person.Cat = CodeMao('可爱', '喵喵')
elif person.Cat.IQ >= 100:
print('恭喜你,喵喵已升级为唱歌喵')
person.Cat = SingCat('可爱', '喵喵')
else:
person.Cat = Cat('可爱', '喵喵')
time.sleep(1.5)
p=Person()
a1=threading.Thread(target=see, args=(p,))
a2=threading.Thread(target=catset, args=(p,))
a3 = threading.Thread(target=main, args=(p,))
a1.start()
a2.start()
a3.start()点赞0
评论