2014-08-22 21:57:54 +03:00
|
|
|
package com.iluwatar;
|
|
|
|
|
2014-08-31 11:17:21 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Observer pattern defines one-to-many relationship
|
|
|
|
* between objects. The target object sends change
|
|
|
|
* notifications to its registered observers.
|
|
|
|
*
|
|
|
|
*/
|
2014-08-22 21:57:54 +03:00
|
|
|
public class App
|
|
|
|
{
|
|
|
|
public static void main( String[] args )
|
|
|
|
{
|
|
|
|
|
|
|
|
Weather weather = new Weather();
|
|
|
|
weather.addObserver(new Orcs());
|
|
|
|
weather.addObserver(new Hobbits());
|
|
|
|
|
|
|
|
weather.timePasses();
|
|
|
|
weather.timePasses();
|
|
|
|
weather.timePasses();
|
|
|
|
weather.timePasses();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|