Search code examples
c++classumlclass-diagram

How to differentiate multiple classes with the same function


Lets say I have a room with two doors. A central system is controlling both of them. This is done by using sockets. The DoorController class has to implement two instances of door. These door classes have an interface to talk to the socket. How do I implement these two classes with the same behaviour in my class diagram so that DoorController knows which door he is operating?


Solution

  • If I understand you problem well, you should have one class called DoorController and two objects called door_1 and door_2. The class DoorController should have a member variable called ID and you can then change this member variable in door_1 and door_2 with two different values.