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