Sunday, December 11, 2016

Perancangan Perangkat Lunak Menggunakan Design Pattern

Menggunakan Observer Pattern di weather program. weather program adalah program yang akan menampilkan keadaan cuaca dan memberikan pemberitahuan mengenai cuaca yang ada. Dengan beberapa variabel yang akan menentukan cuaca yang akan terjadi.

1. CurrentConditionsDisplay.java


2. DisplayElement.java
3. ForecastDisplay.java
4. HeatIndexDisplay.java


5. Observer.java

6. StatisticDisplay.java
7. Subject.java

8. WeatherData.java

9. WeatherStation.java


10. WeatherStationHeatIndex.java


Hasil
  • Current conditions: 80.0F degrees and 65.0% humidity
    Avg/Max/Min temperature = 80.0/80.0/80.0
    Forecast: Improving weather on the way!
    Heat index is 82.95535
    Current conditions: 82.0F degrees and 70.0% humidity
    Avg/Max/Min temperature = 81.0/82.0/80.0
    Forecast: Watch out for cooler, rainy weather
    Heat index is 86.90124
    Current conditions: 78.0F degrees and 90.0% humidity
    Avg/Max/Min temperature = 80.0/82.0/78.0
    Forecast: More of the same
    Heat index is 83.64967

Referensi:
https://github.com/bethrobson/Head-First-Design-Patterns/tree/master/src/headfirst/designpatterns/observer/weather

No comments:

Post a Comment