Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
AIM:-Implement the Code for controlling the retraction and extension of Airplane’s landing gear
CODE:-
#include<iostream>
using namespace std;
string lights,lever;
void setLightsRed()
{
lights = "Red";
}
void setLightsGreen()
{
lights= "Green";
}
void setLightsOff()
{
lights = "Off";
}
string getLights()
{
return lights;
}
void setLeverUp()
{
lever = "Up";
}
void setLeverDown()
{
lever = "Down";
}
string getLever()
{
return lever;
}
string takeOff()
{
if(getLights() != "Red" )
return "Can't take off because lights are not red\n";
setLeverUp();
setLightsOff();
return "Take Off Success\n";
}
string landing()
{
if(getLights() != "Green" )
return "Can't land because lights are not Green\n";
setLeverDown();
return "Landing Success\n";
}
int main()
{
setLightsRed();
cout<<takeOff();
setLightsGreen();
cout<<landing();
return 0;
}