1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include <iostream>
#include <vector>
#include <map>
using namespace std;
class Seat{
public:
int number;
char letter;
bool taken;
Seat(int number,char letter):
number(number),letter(letter){
taken = false;
}
Seat(){
number = 0;
letter = 'Z';
taken = false;
}
Seat(const Seat &other){
letter = other.letter;
taken = other.taken;
number = other.number;
}
Seat& operator =(const Seat& other){
letter = other.letter;
taken = other.taken;
number = other.number;
return *this;
}
bool operator<(const Seat& other)const{
return number == other.number;
}
};
class Airline{
public:
string name;
int flightNumber;
map<Seat,Seat> seats;
Airline(string name,int flightNumber)
: flightNumber(flightNumber),name(name){}
Airline(){
}
void addSeats(int row,char letter){
for(int i = 1; i < row; i++){
for(char j = 'A'; j <= letter; j++){
Seat seat(i,j);
seats[Seat(i,j)] = seat;
}
}
}
void printSeats(int row,char letter){
for(int i = 1; i < row; i++){
for(char j = 'A'; j <= letter; j++){
cout << seats[Seat(i,j)].number << seats[Seat(i,j)].letter << endl;
}
}
}
};
int main()
{
Airline Delta("Delta",101);
Delta.addSeats(50,'F');
Delta.printSeats(50,'F');
}
|