#include #include class Date{ private: int day; int month; int year; public: Date(); Date(int,int,int); Date(const Date&); ~Date() = default; void set_day(int day){ this->day = day; } void set_month(int month){ this->month = month; } void set_year(int year){ this->year = year; } int get_day(){ return this->day; } int get_month(){ return this->month; } int get_year(){ return this->year; } friend std::ostream& operator <<(std::ostream& out, const Date& obj){ out << obj.day << "." << obj.month << "." << obj.year << std::endl; } }; Date::Date(){ day = 1; month = 1; year = 2022; } Date::Date(int day,int month,int year){ this->day = day; this->month = month; this->year = year; } Date::Date(const Date& obj){ this->day = obj.day; this->month = obj.month; this->year = obj.year; } class Tour{ private: std::string country; int count_days; int count_people; int level; Date date; double price; public: Tour(); Tour(std::string,int,int,int,Date,double); ~Tour() = default; std::string get_country(){ return this->country; } int get_count_days(){ return this->count_days; } int get_count_people(){ return this->count_people; } int get_level(){ return this->level; } double get_price(){ return this->price; } void set_country(std::string country){ this->country = country; } void set_count_days(int count_days){ this->count_days = count_days; } void set_count_people(int count_people){ this->count_people = count_people; } void set_level(int level){ this->level = level; } void set_price(double price){ this->price = price; } void ShowAll(); void EnterInfo(); }; Tour::Tour(){ country = "country"; count_days = 0; count_people = 0; level = 2; price = 0; } Tour::Tour(std::string country,int count_days,int count_people,int level,Date date,double price){ this->country = country; this->count_days = count_days; this->count_people = count_people; this->level = level; this->date = date; this->price = price; } void Tour::ShowAll(){ std::cout << "______Поїздка______" << std::endl; std::cout << "Країна: " << country << std::endl; std::cout << "Кiлькiсть днiв: " << count_days << std::endl; std::cout << "Кiлькiсть людей: " << count_people << std::endl; std::cout << "Рiвень: " << level << std::endl; std::cout << "Дата: " << date; std::cout << "Цiна: " << price << std::endl; std::cout << "___________________" << std::endl; } void Tour::EnterInfo(){ std::string tmp_str; int tmp_int; double tmp_double; std::cout << "\tВвiд iнформацiї" << std::endl; std::cout << "Країна: "; std::cin >> tmp_str; this->country = tmp_str; std::cout << "Кiлькiсть днiв: "; std::cin >> tmp_int; this->count_days = tmp_int; std::cout << "Кiлькiсть людей: "; std::cin >> tmp_int; this->count_people = tmp_int; bool flag = false; do{ std::cout << "Рiвень(2-5): "; std::cin >> tmp_int; if(tmp_int < 2 || tmp_int > 5){ std::cout << "Неправильно введена iнформацiя.Спробуйте ще раз." << std::endl; } else{ this->level = tmp_int; flag = true; } } while(!flag); std::cout << "---Дата---" << std::endl; std::cout << "День: "; std::cin >> tmp_int; date.set_day(tmp_int); std::cout << "Мiсяць: "; std::cin >> tmp_int; date.set_month(tmp_int); std::cout << "Рiк: "; std::cin >> tmp_int; date.set_year(tmp_int); std::cout << "----------" << std::endl; std::cout << "Цiна: "; std::cin >> tmp_double; this->price = tmp_double; } void Enter_Current_Date(Date&); void Enter_List(Tour* , const int); void Show_List(Tour* , const int); void Find_Country(Tour*, const int, std::string); void Find_Price_Level_7days(Tour*, const int); int main(){ setlocale(LC_ALL,"Ukrainian"); Date dt; int size; std::string find; std::cout << "\tВведiть поточну дату" << std::endl; Enter_Current_Date(dt); std::cout << "Введiть кiлькiсть поїздок: "; std::cin >> size; Tour *list = new Tour[size]; Enter_List(list,size); system("cls"); Show_List(list,size); std::cout << "Введiть країну: "; std::cin >> find; Find_Country(list,size,find); Find_Price_Level_7days(list,size); delete[] list; return 0; } void Enter_Current_Date(Date &obj){ int temp; std::cout << "День: "; std::cin >> temp; obj.set_day(temp); std::cout << "Мiсяць: "; std::cin >> temp; obj.set_month(temp); std::cout << "Рiк: "; std::cin >> temp; obj.set_year(temp); } void Enter_List(Tour *list, const int size){ for(int i = 0; i < size; i++){ list[i].EnterInfo(); } } void Show_List(Tour *list, const int size){ for(int i = 0; i < size; i++){ list[i].ShowAll(); } std::cout << std::endl; } void Find_Country(Tour* list,const int size, std::string country){ bool flag = false; std::cout << "Знайденi поїздки за країною " << country << ": "<< std::endl; for(int i = 0; i < size; i++){ if(list[i].get_country() == country){ flag = true; list[i].ShowAll(); } } if(!flag){ std::cout << "Поїздок не знайдено..." << std::endl; } std::cout << std::endl; } void Find_Price_Level_7days(Tour *list,const int size){ bool flag = false; std::cout << "Знайденi поїздки цiна яких менша 20000, рiвень вiд 4 до 5 на 7 днiв:" << std::endl; for(int i = 0; i < size; i++){ if(list[i].get_price() < 20000 && (list[i].get_level() >= 4 && list[i].get_level() <= 5) && list[i].get_count_days() == 7 ){ list[i].ShowAll(); flag = true; } } if(!flag){ std::cout << "Поїздок не знайдено..." << std::endl; } }