Challenge

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

Overview of the Project: In this project, a Finite State Machine is used to manage the retraction and extension of an airplane's landing gear (FSM). The most efficient algorithm is the FSM, which is a mathematical processing model.

Actually an airplane has 3 gears for landing: Nose gear, Left gear, Right gear.

There is an electrically powered hydraulic pump that applies pressure to the gears to bring it down or pull it up.

There is a limit switch on each leg of the gear. One extra squat switch is installed in the nose gear to assess whether the plane is on the ground or not.

Goals:

Valve's direction can be controlled.

Controlling the retraction and extension of the landing gear on an aeroplane.

CODE:

#include
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();< p=""></landing();<></takeoff();

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.