Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
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.
Goal:
-
Valve's direction can be controlled.
-
Controlling the retraction and extension of the landing gear on an aeroplane.
Program:
#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;
}
OUTPUT:
