I have a simple Controller
object that that implements Observer
(i.e. it is the observer) which listens for events from a Mouse
object that extends Observable
(i.e. it is the observee).
So there can be multiple events in a Mouse
object e.g. left click, scroll up, etc.
Now the Controller
class implements the required method which is called every time any of the above events happen:
@Override
public void update(Observable o, Object arg)
{
}
So it is the arg
parameter that I am having trouble deciding how to approach (this case I am working on is simple enough such that the o parameter is not a concern). What is a good way to distinguish between different mouse events without using typeof?
I.e. what parameter should I feed in the notifyObservers(Object arg)
method in the Mouse
observee class?
Aucun commentaire:
Enregistrer un commentaire