Challenge

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

#include<stdio.h>

//system state declaration
typedef enum
{
Plane_Takeon,
Plane_Landing,
Plane_Moving,
Plane_Takeoff,


}State_Type;

//state table declaration
typedef struct
{
char* Door[2];
char* Gear[2];
char* Landing[2];
State_Type Airplane_state[2];
char* current_state_indication[2];


}State;

//state table formation
State state_Hydraulic_Mechanism[2]={
{{"OPEN","OPEN"},{"DOWN","Enable"},{"LANDING","PLANE LAND"},{Plane_Takeon,Plane_Landing},{"PLANE TAKEON","PLANE LANDING"}},
{{"CLOSE"},{"UP"},{"RUNNING"},{Plane_Moving,Plane_Takeoff},{"PLANE TAKEOFF"}}

};

State_Type current_state;
static int control_input;

int main()
{
current_state = Plane_Takeon;
while(1)
{
printf("Enter the current_input :");
fflush(stdout);
scanf("%d", &control_input);

printf("current state: %s\n",state_Hydraulic_Mechanism[current_state].current_state_indication[control_input]);
printf("Status of Lever Door : %s\n",state_Hydraulic_Mechanism[current_state].Door[control_input]);
printf("Status of Lever Gear : %s\n", state_Hydraulic_Mechanism[current_state].Gear[control_input]);
printf("Status of Plane : %s\n", state_Hydraulic_Mechanism[current_state].Landing[control_input]);
current_state = state_Hydraulic_Mechanism[current_state].Airplane_state[control_input];


}
}

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.