Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- static int newsID = 1;
- static int weatherID = 1;
- class Region {
- private:
- string city;
- int ID;
- public:
- Region() {}
- Region(int _ID, string _city) {
- ID = _ID;
- city = _city;
- }
- #pragma region getters
- int getID() { return ID; }
- string getCity() { return city; }
- #pragma endregion
- };
- class News {
- private:
- int cityID;
- int NewsID;
- string title;
- string newsText;
- public:
- News() {}
- News(int _cityID, string _title, string _newsText) {
- NewsID = newsID;
- cityID = _cityID;
- title = _title;
- newsText = _newsText;
- newsID++;
- }
- #pragma region getters
- int getCityID() { return cityID; }
- int getNewsID() { return NewsID; }
- string getNewsTitle() { return title; }
- void readNews() {
- cout << title << endl << endl << newsText << endl;
- }
- #pragma endregion
- };
- class Weather {
- private:
- int WeatherID;
- int cityID;
- string title;
- string forecast;
- public:
- Weather() {}
- Weather(int _cityID, string _title, string _forecast) {
- WeatherID = weatherID;
- cityID = _cityID;
- title = _title;
- forecast = _forecast;
- weatherID++;
- }
- #pragma region getters
- int getCityID() { return cityID; }
- int getWeatherID() { return WeatherID; }
- string getTitle() { return title; }
- string getForecast() { return forecast; }
- void printForecast(Region region) {
- cout << "Weather in " << region.getCity() << " will be " << forecast << endl;
- }
- #pragma endregion
- };
- void menu(vector<Region> regions, vector<News> news, vector<Weather> weathers);
- void GetAllCitiesNewsAndWeathers(vector<Region> regions, vector<News> news, vector<Weather> weathers);
- void GetAllNews(vector<News> news);
- void GetAllWeathers(vector<Region> regions, vector<Weather> weathers);
- void GetNewsByCity(vector<News> news, Region temp);
- void GetWeatherByCity(vector<Weather> weathers, Region temp);
- void print(string text);
- int main() {
- vector<Region> Regions{
- *new Region(1, "Tbilisi"),
- *new Region(2, "Batumi"),
- *new Region(3, "Gori"),
- *new Region(4, "Qutaisi")
- };
- vector<Weather> Weathers{
- *new Weather(1,"Tbilisis amindi", "38 gradusi"),
- *new Weather(2,"Bautmi amindi", "41 gradusi"),
- *new Weather(3,"Gori amindi", "15 gradusi"),
- *new Weather(4,"Qutaisi amindi", "39 gradusi")
- };
- vector<News> news{
- *new News(1,"Archevnebi","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(1,"R2","ERROR"),
- * new News(2,"Archevnebi","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(2,"temp","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(3,"Archevnebi","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(3,"temp","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(4,"Archevnebi","Meris archevnebi iwkeba 12 oqtombers"),
- * new News(4,"temp","Meris archevnebi iwkeba 12 oqtombers")
- };
- menu(Regions, news, Weathers);
- std::cin.get();
- std::cin.get();
- return 0;
- }
- void menu(vector<Region> regions, vector<News> news, vector<Weather> weathers)
- {
- system("cls");
- print("1) Check news and weathers by Regions");
- print("2) Check all news");
- print("3) Check all weathers");
- int choose;
- std::cin >> choose;
- switch (choose)
- {
- case 1:
- GetAllCitiesNewsAndWeathers(regions, news, weathers);
- break;
- case 2:
- GetAllNews(news);
- break;
- case 3:
- GetAllWeathers(regions, weathers);
- break;
- default:
- break;
- }
- }
- void GetAllCitiesNewsAndWeathers(vector<Region> regions, vector<News> news, vector<Weather> weathers)
- {
- system("cls");
- int ID;
- int infoType;
- Region instance;
- for (auto item : regions)
- {
- cout << item.getID() << ") " << item.getCity() << endl;
- }
- print("Enter ID of city: ");
- std::cin >> ID;
- for (auto item : regions)
- {
- if (ID == item.getID()) {
- instance = item;
- }
- }
- system("cls");
- print("1) Check news for the city");
- print("2) Check weather for the city");
- std::cin >> infoType;
- switch (infoType)
- {
- case 1:
- GetNewsByCity(news, instance);
- break;
- case 2:
- GetWeatherByCity(weathers, instance);
- break;
- default:
- break;
- }
- }
- void GetAllNews(vector<News> news)
- {
- system("cls");
- int index;
- for (auto item : news)
- {
- cout << item.getNewsID() << ") " << item.getNewsTitle()<< endl;
- }
- print("Enter the index of news you are interested in : ");
- std::cin >> index;
- for (auto item : news)
- {
- if (item.getNewsID() == index)
- {
- item.readNews();
- }
- }
- }
- void GetAllWeathers(vector<Region> regions, vector<Weather> weathers)
- {
- system("cls");
- int index;
- Weather wInstance;
- Region rInstance;
- for (auto item : weathers)
- {
- cout << item.getWeatherID() << ") " << item.getTitle();
- }
- print("Enter the index of weather you are interested in : ");
- std::cin >> index;
- for (auto item : weathers)
- {
- if (item.getWeatherID() == index) {
- wInstance = item;
- }
- }
- for (auto item : regions)
- {
- if (item.getID() == wInstance.getCityID()) {
- rInstance = item;
- }
- }
- wInstance.printForecast(rInstance);
- }
- void GetNewsByCity(vector<News> news, Region temp)
- {
- system("cls");
- int newsID;
- for (auto item : news)
- {
- if (item.getCityID() == temp.getID()) {
- cout << item.getNewsID() << ") " << item.getNewsTitle()<< endl;
- }
- }
- print("Enter the index of news you are interested in: ");
- std::cin >> newsID;
- for (auto item : news)
- {
- if (item.getNewsID() == newsID) {
- item.readNews();
- }
- }
- }
- void GetWeatherByCity(vector<Weather> weathers, Region temp)
- {
- system("cls");
- int newsID;
- for (auto item : weathers)
- {
- if (item.getCityID() == temp.getID()) {
- cout << item.getWeatherID() << ") " << item.getTitle() << endl;
- }
- }
- print("Enter the index of news you are interested in: ");
- std::cin >> newsID;
- for (auto item : weathers)
- {
- if (item.getWeatherID() == newsID) {
- item.printForecast(temp);
- }
- }
- }
- void print(string text)
- {
- cout << text << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement