mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-03 07:13:02 +00:00
Comments for observer example.
This commit is contained in:
1 parent
8ddcdac33e
commit
3bc005f4b7
3 files changed
+18
No files matched your search
@@ -1,5 +1,12 @@
|
||||
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 )
|
||||
|
||||
@@ -3,6 +3,12 @@ package com.iluwatar;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Weather can be observed by implementing WeatherObserver
|
||||
* interface and registering as listener.
|
||||
*
|
||||
*/
|
||||
public class Weather {
|
||||
|
||||
private WeatherType currentWeather;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Observer interface.
|
||||
*
|
||||
*/
|
||||
public interface WeatherObserver {
|
||||
|
||||
void update(WeatherType currentWeather);
|
||||
|
||||
Reference in new issue
Block a user