Let's say I have two basic abstract classes with completely different functionality: a laptop and a smartphone. (Assume the functionality is completely different). And in my current project, I already had many implementations of laptops and smartphones, and they were always completely different.
But unexpectedly, I received a request to add a class, which is an implementation of a PC tablet, which actually has the functions of both a smartphone and a laptop. Itβs too late to change the base classes, and in fact Iβm very sure that this PC tablet will appear only once.
The problem is that I should be able to keep my PC tablet in a container for smartphones, but it should also be a laptop because of the inherited functionality (in fact, next to this, in some part of the project, the PC tablet only uses like a laptop, and it doesnβt need the functionality of a smartphone, and it's bad to look at a PC tablet as a smartphone for this particular part of the project). So, I have a PcTabletAsLaptop: a laptop class, this is actually a laptop, not a smartphone.
My solution is to add a wrapper:
class PcTablet : SmartPhone { private PcTabletAsLaptop _pcTablet;
There are 200+ methods, and I want them to be automatically generated from PcTabletAsLaptop.
This solution looks rather complicated. My question is good, or maybe there are simpler ways to do this?
source share