AvaSmith-CodingSamples / Python / Basic Python Skill Examples / launch_pad.py
launch_pad.py
Raw
# Ava Smith
# smi01868
# CSCI 1133H (001)
# Assignment 2

#================
#Purpose: A prototype launchpad to help launch rockets
#Ip: current_state: the state of the rocket prior to the button being pressed("IDLE", "READY", "SAFE", "LAUNCH"), button: the button that is being pressed("start_btn", "safe_btn", "launch_btn", "reset_button")
#Return Values: returns new_state, possibilities: "IDLE", "READY", "LAUNCH" and "SAFE"
#================

def launch_rocket(current_state, button):
    new_state = "IDLE"
#when in idle state
    if(current_state == "IDLE"):
        if(button == "start_btn"):
            new_state = "READY"

#When in ready state
    if(current_state == "READY"):
        if(button == "safe_btn"):
            new_state = "SAFE"

#When in safe state
    if(current_state == "SAFE"):
        if(button == "launch_btn"):
            new_state = "LAUNCH"
        

    
    return new_state