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:
Implement a
WeatherLogger
class that implements theObserver
interface to receive temperature updates from the weather station.The
WeatherLogger
class should include a methodlogTemperature(float temperature)
that logs the temperature to a file. You can use simple console output for logging in this lab.Register the
WeatherLogger
as an observer with theWeatherStation
in theMain
class.Test your implementation by simulating temperature changes using the
WeatherStation
. Verify that theWeatherLogger
receives temperature updates and logs them correctly.
Note:
You can assume that the existing classes (
WeatherStation
,Observer
,WeatherDisplay
, andMobileApp
) 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