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;
	private List<WeatherObserver> observers;

	public Weather() {
		observers = new ArrayList<>();
		currentWeather = WeatherType.SUNNY;
	}

	public void addObserver(WeatherObserver obs) {
		observers.add(obs);
	}

	public void timePasses() {
		WeatherType[] enumValues = WeatherType.values();
		currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
		System.out.println("The weather changed to " + currentWeather + ".");
		notifyObservers();
	}

	private void notifyObservers() {
		for (WeatherObserver obs : observers) {
			obs.update(currentWeather);
		}
	}
}

@@ -198,23 +198,25 @@
 c class 
-Weather
+TimeOfDay
  %7B%0A%0A%09pri
@@ -299,23 +299,25 @@
 %09public 
-Weather
+TimeOfDay
 () %7B%0A%09%09o

Update TimeOfDay.java