Nov-09-2022, 10:27 AM
Hi deanhystad
Is inheritance the only way to achieve this?
I do not want to implement this via inheritance, because the 2 classes may not always be related.
Let me explain. I'm trying to write a simple table driven agent program (vacuum cleaner cleaning 2 rooms - the classic AI example). In this program the vacuum cleaner must set the room status to "clean" after cleaning it.
Thus, the vacuum object must call the room object's room.set_status('c').
In this scenario a room and a vacuum is not the same type of object and thus implementing inheritance between the room and vacuum classes does not make sense, not so?
Is there no other way to achieve this goal?
Is inheritance the only way to achieve this?
I do not want to implement this via inheritance, because the 2 classes may not always be related.
Let me explain. I'm trying to write a simple table driven agent program (vacuum cleaner cleaning 2 rooms - the classic AI example). In this program the vacuum cleaner must set the room status to "clean" after cleaning it.
Thus, the vacuum object must call the room object's room.set_status('c').
In this scenario a room and a vacuum is not the same type of object and thus implementing inheritance between the room and vacuum classes does not make sense, not so?
Is there no other way to achieve this goal?