Challenge

Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear

//Implement the Code for controlling the retraction and extension of Airplane’s landing gear

#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;
}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.