我需要开发一个特定的 sw 模块,它以以下格式输出数据主要对象和相关对象和数量
IE
Desktop Computer
---- CPU 1x
---- Mouse 1x
---- KB 1x
---- Monitor 1x
---- Speakers 2x
这意味着对于台式计算机对象,应有 1 个 CPU、1 个鼠标、1 个键盘、1 个监视器、2 个扬声器
Cubicles
---------- Desktop Comps 4x (shall mean each cubicle shall contain 4 pc's)
---------- Power Supply 1x (shall mean each cubicle shall have a main pow.
supply)
同样,对于每个 Cubicle 对象,应有 4 个桌面和 1 个电源对象
规则:每 4 个隔间应有一个 HUB 对象
The sample Output for 8 cubicles shall be
Total CPU's - 32
HUB - 2
Mouse - 32
KB - 32
Monitor - 32
Speakers - 64
Cubicles - 8
Desktop PC's - 32
Pow. Supply - 8
任何人都可以帮助我在 OOP 类/接口方面实现相同的目标吗?或者指向在这种情况下使用的设计模式的指针。非常感谢您的时间