0
点赞
收藏
分享

微信扫一扫

内存(Display)、显示器(Monitor)和计算机(Computer)均属于一种产品(Product),其中计算机需要显示器和内存。请用Python语言简要实现这些类及它们之间的关系。


内存(Display)、显示器(Monitor)和计算机(Computer)均属于一种产品(Product),其中计算机需要显示器和内存。请用Python语言简要实现这些类及它们之间的关系。

class Product:
pass


class Display(Product):
def __init__(self, size):
self.size = size


class Monitor(Product):
def __init__(self, length, width):
self.length, self.width = length, width


class Computer(Product):
def __init__(self, size, length, width):
self.display = Display(size)
self.monitor = Monitor(length, width)



举报

相关推荐

0 条评论