diff --git a/Lab_works.iml b/Lab_works.iml
new file mode 100644
index 0000000..205584e
--- /dev/null
+++ b/Lab_works.iml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Exam/WeatherSystem.java b/src/Exam/WeatherSystem.java
new file mode 100644
index 0000000..ffb30dc
--- /dev/null
+++ b/src/Exam/WeatherSystem.java
@@ -0,0 +1,118 @@
+package Exam;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
+
+public class WeatherStation {
+ private static WeatherStation instance;
+ private String stationName;
+ public List weatherDataHistory;
+
+ private WeatherStation(String stationName) {
+ this.stationName = stationName;
+ this.weatherDataHistory = new ArrayList<>();
+ }
+
+ public static WeatherStation getInstance(String stationName) {
+ if (instance == null) {
+ instance = new WeatherStation(stationName);
+ }
+ return instance;
+ }
+
+ public String getWeatherData() {
+ String currentWeather = "Weather data.\nTemperature: " + ThreadLocalRandom.current().nextInt(-20, 41);
+ weatherDataHistory.add(currentWeather);
+ return currentWeather;
+ }
+
+ public List getWeatherDataHistory() {
+ return weatherDataHistory;
+ }
+
+ public class WeatherProxy {
+ private WeatherStation weatherStation;
+ private String stationName;
+ private WeatherObserver observer;
+
+ public WeatherProxy(String stationName) {
+ this.stationName = stationName;
+ }
+
+ private void checkExists() {
+ if (weatherStation == null) {
+ this.weatherStation = WeatherStation.getInstance(stationName);
+ }
+ }
+
+ public String getWeatherData() {
+ checkExists();
+
+ observer.notify();
+ return weatherStation.getWeatherData();
+ }
+
+ public List getWeatherDataHistory() {
+ checkExists();
+
+ observer.notify();
+ return weatherStation.getWeatherDataHistory();
+ }
+
+
+ public WeatherIterator iterator() {
+ return new WeatherIterator(this.getWeatherDataHistory());
+ }
+ }
+
+ public class WeatherObserver {
+ private WeatherProxy weatherStation;
+ private List