Challenge

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

 
#include
#include
#include
 
char lights[10];
char lever[10];
 
void setLightsRed(void);
void setLightsGreen(void);
void setLightsOff(void);
char* getLights(void);
void setLeverUp(void);
void setLeverDown(void);
char* getLever(void);
char* takeOff(void);
char* landing(void);
 
 
int main(){
    setLightsRed();
    printf("%s \n", takeOff());
    setLightsGreen();
    printf("%s \n", landing());
    return 0;
}
 
void setLightsRed(){
    strcpy(lights, "Red");
}
 
void setLightsGreen(){
    strcpy(lights, "Green");
 
}
 
void setLightsOff(){
    strcpy(lights, "Off");
}
 
char* getLights(){
   return lights;
}
 
void setLeverUp(){
    strcpy(lever, "Up");
}
 
void setLeverDown(){
    strcpy(lever, "Down");
}
 
char* getLever(){
   return lever;
}
 
char* takeOff(){
    char* lights_status = getLights();
//    printf("lights_status %s \n", lights_status);
    if(strcmp(lights_status, "Red") != 0){
        return "Can't take off because lights are not Red\n";
    }
    setLeverUp();
    setLightsOff();
    return "Take Off Success\n";
}
 
char* landing(){
    char* lights_status = getLights();
//    printf("lights_status %s \n", lights_status);
    if(strcmp(lights_status, "Green") != 0){
        return "Can't land because lights are not Green\n";
     }
    setLeverDown();
    return "Landing Success\n";
}
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.