mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
24 lines
529 B
Java
24 lines
529 B
Java
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 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();
|
|
|
|
}
|
|
}
|