Writing /volume1/Web/Public/dokuwiki/data/log/deprecated/2024-11-14.log failed
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
study:java:design_pattern:observer [2008/08/12 15:24] – banana | study:java:design_pattern:observer [2009/07/08 07:40] (現在) – banana | ||
---|---|---|---|
行 15: | 行 15: | ||
한번 직접 살펴보죠. | 한번 직접 살펴보죠. | ||
+ | {{keywords> | ||
===== Class Diagram ===== | ===== Class Diagram ===== | ||
{{: | {{: | ||
- | ===== Design | + | ===== Design of weather report |
{{: | {{: | ||
行 38: | 行 39: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
===== snippet of WeatherData ===== | ===== snippet of WeatherData ===== | ||
+ | <code java> | ||
+ | public class WeatherData implements Suject{ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | int i = observers.indexOf(o); | ||
+ | | ||
+ | observers.remove(i); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | Observer observer = (Observer) observers.get(i); | ||
+ | observer.update(temperature, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | // | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== snippet of CurrentConditionsDisplay ===== | ||
+ | <code java> | ||
+ | public class CurrentConditionsDisplay implements Observer, DisplayElement{ | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Test class ===== | ||
+ | <code java> | ||
+ | public class WeatherStation{ | ||
+ | public static void main(String[] args){ | ||
+ | | ||
+ | |||
+ | | ||
+ | new CurrentConditionsDisplay(weatherData); | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||