Good day, everybody!
Here is where I stuck:
I have three concrete classes: Computer
, Peripheral
and Person
.
Computer
and Peripheral
are both extend class Device
.
Device
has a private member Device.owner
: Person
, which should store some kind of a reference to an owner of the device, and a public function Device.getOwner()
: Person
.
On the other hand, any Person
has its own private members Person.peripherals
and Person.computers
and public functions Person.get()
... etc.
Is there are any design patterns to build these connections between classes?
Without transferring direct ownership! (the Computer
has no rights to kill instance of Person
etc. that is why I beware of using pointers)
BUT if some instances of Computer
will change its owner so it must be disappeared from the list of computers of the previous owner and appeared in the list of the new owner. Same thing with Peripheral
.
Please, ask any questions if you have some. Probably, my explanation of the situation is poor. Sorry for lang mistakes.