I am new to Java. After simply reading the path discovery information, I read about using an empty class as " interface" for an unknown object type.
I am developing a game in Java based on a hospital theme. Until now, the user can create a reception and office GP. They are two different types of object, one - Buildingand one - ReceptionDesk. (In my class structure.)
My class structure is as follows:
GridObject-->Building
GridObject-->Item-->usableItem-->ReceptionDesk.
The problem arises when the useful element can be rotated, but the building cannot. The mouse click event is in the grid, so it calls the same method. The GP office is Buildingand the reception is ReceptionDesk. Only ReceptionDeskhas a method rotate. When right-clicking on a grid, if in build mode I have to use this "if" expression:
if (currentBuilding.getClass.equals(ReceptionDesk.getClass)
Then I need to create a new one ReceptionDesk, use the method rotate, and put the receptionist back in currentBuilding GridObject.
I'm not sure that I explain this question very well. I'm sorry. I am still new to Java. I will try to answer any questions, and I can post more code snippets if necessary. I did not know that there might be a problem with the fact that you do not know the class of the object, but I could also be wrong.
, , !:)
.
Rel