Skip to content

Instantly share code, notes, and snippets.

@bilinin
Created February 28, 2017 14:04
Show Gist options
  • Save bilinin/12afcf70f4685a880d80eaa65a2ee568 to your computer and use it in GitHub Desktop.
Save bilinin/12afcf70f4685a880d80eaa65a2ee568 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
struct Ttime{
int hour;
int minute;
};
class Aeroflot{
public:
// Конструктор
Aeroflot(string Destination, string FlightNumber, string PlaneType, Ttime Time, string Day){
set_destination(Destination);
set_flight_number(FlightNumber);
set_plane_type(PlaneType);
set_time(Time);
set_day(Day);
}
// Сеттеры
void set_destination(string destination){
Destination = destination;
}
void set_flight_number(string flight_number){
FlightNumber = flight_number;
}
void set_plane_type(string plane_type){
PlaneType = plane_type;
}
void set_time(Ttime time){
Time = time ;
}
void set_day(string day){
Day = day ;
}
// Геттеры
string get_destination(){
return Destination;
}
string get_flight_number(){
return FlightNumber;
}
string get_plane_type(){
return PlaneType;
}
Ttime get_time(){
return Time;
}
string get_day(){
return Day;
}
// other
void print_all_data(){
cout << Destination << " " << FlightNumber << " " << PlaneType << " "
<< " " << Day<< " "<< Time.hour << ":" << Time.minute << endl;
}
private:
string Destination,
FlightNumber,
PlaneType,
Day;
Ttime Time;
};
void show_for_destination(vector <Aeroflot> Aeroflots, string desination){
cout << "Planes to " << desination << endl;
int size = Aeroflots.size();
for (int i = 0;i<size; i++){
if(Aeroflots[i].get_destination() == desination){
Aeroflots[i].print_all_data();
}
}
}
void show_for_day(vector <Aeroflot> Aeroflots, string day){
cout << "\n\nDay is " << day << endl;
int size = Aeroflots.size();
for (int i = 0;i<size; i++){
if(Aeroflots[i].get_day() == day){
Aeroflots[i].print_all_data();
}
}
}
void show_for_day_time(vector <Aeroflot> Aeroflots, string day, Ttime time){
cout << "\n\nDay is " << day << ", time more then " << time.hour<< ":" << time.minute << endl;
int size = Aeroflots.size();
for (int i = 0;i<size; i++){
Ttime current_time = Aeroflots[i].get_time();
if((Aeroflots[i].get_day() == day) && (current_time.hour > time.hour) && (current_time.minute > time.minute)){
Aeroflots[i].print_all_data();
}
}
}
int main() {
vector <Aeroflot> Aeroflots;
Aeroflots.push_back(Aeroflot("Moskow", "777", "Boing", {10,40}, "Monday"));
Aeroflots.push_back(Aeroflot("Ekaterinburg", "123", "Boing", {3,30}, "Saturday"));
Aeroflots.push_back(Aeroflot("Ekaterinburg", "653", "Boing", {1,40}, "Wednesday"));
Aeroflots.push_back(Aeroflot("Moskow", "524", "Boing", {15,20}, "Wednesday"));
Aeroflots.push_back(Aeroflot("Moskow", "634", "Boing", {20,32}, "Monday"));
show_for_destination(Aeroflots, "Moskow");
show_for_day(Aeroflots, "Monday");
show_for_day_time(Aeroflots, "Wednesday", {1,10});
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment