Comments for observer example.
This commit is contained in:
parent
8ddcdac33e
commit
3bc005f4b7
@ -1,5 +1,12 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Observer pattern defines one-to-many relationship
|
||||||
|
* between objects. The target object sends change
|
||||||
|
* notifications to its registered observers.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class App
|
public class App
|
||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
|
@ -3,6 +3,12 @@ package com.iluwatar;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Weather can be observed by implementing WeatherObserver
|
||||||
|
* interface and registering as listener.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Weather {
|
public class Weather {
|
||||||
|
|
||||||
private WeatherType currentWeather;
|
private WeatherType currentWeather;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Observer interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface WeatherObserver {
|
public interface WeatherObserver {
|
||||||
|
|
||||||
void update(WeatherType currentWeather);
|
void update(WeatherType currentWeather);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user