Question: C++ #include #include using namespace std; class Seat { public: inline Seat() { open = true; } inline bool isOpen() const { return open; }

C++ #include #include using namespace std; class Seat { public: inline Seat()C++

#include

#include

using namespace std;

class Seat

{

public:

inline Seat() { open = true; }

inline bool isOpen() const { return open; }

inline void setOpen(bool b) { open = b; }

inline void printSeat() const

{

cout

}

private:

bool open;

};

class FirstClass

{

public:

FirstClass();

void printFC() const;

bool assignFC(int num, char type);

private:

vector > fs;

};

FirstClass::FirstClass()

{

vector vs(4);

for (int i = 0; i

fs.push_back(vs);

}

void FirstClass::printFC() const

{

for (int i = 0; i

{

for (int j = 0; j

{

fs[i][j].printSeat();

if (j % 2 != = 0)

cout

}

}

}

bool FirstClass::assignFC(int num, char type)

{

switch (type)

{

case 'w':

for(int i=0;i

for(int j=0;j

if (fs[i][j].isOpen())

{

fs[i][j].setOpen(false); return true;

}

return false;

break;

case 'i':

for(int i=0;i

for(int j=1;j

if (fs[i][j].isOpen())

{

fs[i][j].setOpen(false); return true;

}

return false;

break;

}

}

class Plane

{

public:

inline Plane() { c = FirstClass(); }

inline bool assignSeats(int num, char type) { return c.assignFC(num, type); }

inline void print() const { c.printFC(); }

private:

FirstClass c;

};

class ReservationSystem

{

public:

inline ReservationSystem() { fcFee = 1000; ecFee = 300; }

inline bool addPassenger(int num, char type, Plane& p) { return p.assignSeats(num, type); }

inline void showSeats(Plane p) const { p.print(); }

inline bool quit() const { cout

private:

double fcfee;

double ecfee;

};

int main()

{

Plane p280;

ReservationSystem rs;

rs.showSeats(p280);

rs.addPassenger(1, 'i', p280);

rs.showSeats(p280);

return 0;

}

Assign seats on a plane. The airplane has 20 seats in first class (5 rows, 4 seats each, separated by a aisle) and 180 seats in economy class (30 rows of 6 seats each, separated by an aisle) Three commands: add passengers, show seating, and quit. When passengers are added, ask for the class (first or economy), the number of passengers traveling together (1 or 2 in first class; 1 to 3 in economy), and the seating preference (aisle or window in first class; aisle, center, or window in economy) Then try to find a match and assign the seats. If no match exists, print a message. Your user interface can be text-based or graphical

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!