Challenge

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

#include<stdio.h>

#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 "\ncan't land because lights are not red";}

setleverup();

setlightsoff();

return "\ntake off successfull";

}

string landing()

{

if(getlights() != "green"){

return "\ncan't land because lights are not green"; }

setleverdown();

setlightsoff();

return "\nlanding successfull";

}

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.