Module 8 Lab - Weather Station (Observer Pattern)

Lab Assignment: Implement Additional Observer

You have been given a weather station system that uses the Observer pattern to notify observers about temperature changes. Your task is to extend the system by implementing an additional observer: a WeatherLogger that logs temperature updates to a file.

Requirements:

  1. Implement a WeatherLogger class that implements the Observer interface to receive temperature updates from the weather station.

  2. The WeatherLogger class should include a method logTemperature(float temperature) that logs the temperature to a file. You can use simple console output for logging in this lab.

  3. Register the WeatherLogger as an observer with the WeatherStation in the Main class.

  4. Test your implementation by simulating temperature changes using the WeatherStation. Verify that the WeatherLogger receives temperature updates and logs them correctly.

Note:

  • You can assume that the existing classes (WeatherStation, Observer, WeatherDisplay, and MobileApp) are already implemented correctly.

  • You can use the existing code provided in the previous example as a starting point for your implementation.

Submission:

  • Submit the modified WeatherLogger class as a separate file or as part of the existing project.

  • Include any additional instructions or notes necessary for running and testing your code.

Good luck with your lab assignment!

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark