Hello all,
I have a question about Observable class. I heard it's possible to send an object with the method notifyObservers();
At this moment I am sending a
string, that works fine, but I like to send an object that my Observer class can read this objects variable value.
So far I have the following pices of code:
My Observer (a clock) it's update method:
My Observable class TimeGenerator that updates my clocks every 1 sec:
As you can see I am sending the class TimeGenerator as argument. The Observer class checks if it's a class of TimeGenerator.
Now I like to read the information from this arg object.
I tried making a method in TimeGenerator:
But I cannot access it with the statement : arg.getSecond();
I like to keep the field private.
How can I read the field of the object TimeGenerato that is send?