轻松的编程学习
首页
题库
学习路径
在线商城
能力地图
下载应用
登录 / 注册
菜单
⚠️ 给模型量三个数
👁️ 2 人浏览
💬 0 人评论
❤️ 添加收藏
量一量这个模型:几个类、组装层持有几个零件、继承有多深。
提交你的答案
请登录后提交答案。
去登录
← ⚠️ 给自己的模型体检
测一个 OOP 模型,先测哪一层 →
更多题目
让程序说出"你好"
让程序欢迎你
哪个命令能显示内容
哪里是指令,哪里是结果
让程序说出你的名字
这个程序会显示什么
代码编辑器
语言:
python3
c11
cpp17
Ctrl
+
Enter
运行
👩🏫 AI
▶ 运行代码
重置代码
打印代码
class Shape: def area(self): raise NotImplementedError class Rect(Shape): def __init__(self, w, h): self.w, self.h = w, h def area(self): return self.w * self.h class Formatter: def render(self, shape): return "面积=" + str(shape.area()) class Store: def __init__(self): self.box = [] def save(self, text): self.box.append(text) class Reporter: def __init__(self, fmt, store): self.fmt, self.store = fmt, store def report(self, shape): self.store.save(self.fmt.render(shape)) # TODO: 三个数:这个模型里有几个类、Reporter 持有几个零件、 # TODO: 以及 Rect 到 Shape 的继承深度(Rect 算 1 层) CLASSES = [Shape, Rect, Formatter, Store, Reporter] n_class, n_hold, depth = -1, -1, -1 print(str(n_class) + "/" + str(n_hold) + "/" + str(depth))
本次输入:
输出:
👩🏫
AI
请登录后使用 AI 老师
×
登录后可获得解题思路、提示与错误分析。
去登录
关闭
🎉
恭喜你,回答正确!
系统判定:正确
我知道了
💬 题目评论
提交
全部评论
全部评论