posted 12 years ago
In which situation (how) can I access the class B in the class C then? I know that class A can access B with the getValue() method, because it has an reference to the instance B.
But with Class C which has no reference I don't know. Creating a new instance of class B in class C is not good because I like to access the only one class B I created.
Perhaps the following code will explain it why I like to do this.
Goal:
- want to create a class ClockPanelDigital, want to seprate analog and digital clock panel
problem:
- my current class ClockPanelAnalog creates the ClockPanel, thus ClockPanelAnalog can call ClockPanel's method addPanel(object ClockPanelAnalog)
This adds the clockPanel to the clock frame. But how do I add another clockpanelDigital to the same ClockFrame?
Extra info:
- I have to let ClockPanelAnalog create the instance of ClockPanel, so that the TimeGenerator instance can add ClockPanelAnalog as an Observer.