From 0aa3be643ec04adeb0987ec0641bd7daa60f4992 Mon Sep 17 00:00:00 2001 From: Pavetr Date: Tue, 21 Apr 2026 10:26:40 +0300 Subject: [PATCH] Implemented Weather class fields, constructor and output --- Weather.cpp | 15 +++++++++++++++ Weather.h | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Weather.cpp create mode 100644 Weather.h diff --git a/Weather.cpp b/Weather.cpp new file mode 100644 index 0000000..49d5933 --- /dev/null +++ b/Weather.cpp @@ -0,0 +1,15 @@ +#include "Weather.h" + +Weather::Weather(const std::string& city, double lon, double lat, double temperature, + const std::string& weather, double windSpeed, int clouds) + : city(city), lon(lon), lat(lat), temperature(temperature), + weather(weather), windSpeed(windSpeed), clouds(clouds) { +} + +void Weather::printWeather() const { + std::cout << "City: " << city << " (Lat: " << lat << ", Lon: " << lon << ")\n" + << "Temperature: " << temperature << " deg. C\n" + << "Weather: " << weather << "\n" + << "Wind Speed: " << windSpeed << " m/s\n" + << "Cloudness: " << clouds << " %\n"; +} diff --git a/Weather.h b/Weather.h new file mode 100644 index 0000000..400e32b --- /dev/null +++ b/Weather.h @@ -0,0 +1,19 @@ +#include +#include + +class Weather { +private: + std::string city; // Киров + double lon; // 49.6601 + double lat; // 58.5966 + double temperature; // 5.69 + std::string weather; // дождь + double windSpeed; // 4.27 + int clouds; // 100 + +public: + Weather(const std::string& city, double lon, double lat, double temperature, + const std::string& weather, double windSpeed, int clouds); + + void printWeather() const; +};