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