#include <iostream>
using namespace std;
#include "Headers.h"
void main ()
{
Plane Alfa;
Plane Bravo;
Plane Lounge;
Party NewArrival; // this contains the info about the next party to arrive
char * pPlaneName;
bool Shutdown = false;
bool RightCommand = false;
do
{
cout << "Please enter a command: ";
pPlaneName = ReadString();
if (_strcmpi (pPlaneName, "ALFA") == 0)
{
cout << "Number of seats on ALFA: ";
Alfa.NumSeats = ReadInt ();
Alfa.HowManyOccupied = 0;
Alfa.HowManyParties = 0;
Alfa.Who = new Party [Alfa.NumSeats];
}
else if (_strcmpi (pPlaneName, "BRAVO") == 0)
{
cout << "Number of seats on BRAVO: ";
Bravo.NumSeats = ReadInt ();
Bravo.HowManyOccupied = 0;
Bravo.HowManyParties = 0;
Bravo.Who = new Party [Bravo.NumSeats];
}
else if (_strcmpi (pPlaneName, "LOUNGE") == 0)
{
cout << "Number of seats in the LOUNGE: ";
Lounge.NumSeats = ReadInt ();
Lounge.HowManyOccupied = 0;
Lounge.HowManyParties = 0;
Lounge.Who = new Party [Lounge.NumSeats];
}
else if (_strcmpi (pPlaneName, "ARRIVE") == 0)
{
do
{
cout << "Which plane: ";
pPlaneName = ReadString ();
if (_strcmpi (pPlaneName, "ALFA") == 0)
{
NewArrival.Plane = 'A';
RightCommand = true;
}
else if (_strcmpi (pPlaneName, "BRAVO") == 0)
{
NewArrival.Plane = 'B';
RightCommand = true;
}
else
{
cout << "Bad Command" << endl;
cout << endl;
}
}while (!RightCommand);
RightCommand = false;
cout << "Name of party: ";
NewArrival.pName = ReadString ();
cout << "Number in party: ";
NewArrival.Size = ReadInt ();
if (NewArrival.Plane == 'A')
FitOntoPlane (Alfa, Lounge, NewArrival);
else if (NewArrival.Plane == 'B')
FitOntoPlane (Bravo, Lounge, NewArrival);
if (Alfa.HowManyOccupied == Alfa.NumSeats)
FlyAlfa (Alfa, Lounge, 'A');
else if (Bravo.HowManyOccupied == Bravo.NumSeats)
FlyBravo (Bravo, Lounge, 'B');
}
else if (_strcmpi (pPlaneName, "FLY") == 0)
{
do
{
cout << "Which plane: ";
pPlaneName = ReadString();
if (_strcmpi (pPlaneName, "ALFA") == 0)
{
FlyAlfa (Alfa, Lounge, 'A');
RightCommand = true;
}
else if (_strcmpi (pPlaneName, "BRAVO") == 0)
{
FlyBravo (Bravo, Lounge, 'B');
RightCommand = true;
}
else
{
cout << "Bad Command" << endl;
cout << endl;
}
} while (!RightCommand);
RightCommand = false;
}
else if (_strcmpi (pPlaneName, "SHUTDOWN") == 0)
{
do
{
FlyAlfa (Alfa, Lounge, 'A');
} while (Alfa.HowManyOccupied != 0);
do
{
FlyBravo (Bravo, Lounge, 'B');
} while (Bravo.HowManyOccupied !=0);
Shutdown = true;
}
else
cout << "Bad Command" << endl;
cout << endl;
delete [] pPlaneName;
} while (!Shutdown);
} |