/**
 * The AwaitingCombination State (for a garage door Controller)
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class AwaitingCombination extends State
{
    private        Controller           controller;
    private static AwaitingCombination  instance;
    

    /**
     * Explicit Value Constuctor 
     * [used by the enter() method]
     *
     * @param controller   The Controller to use
     */
    private AwaitingCombination(Controller controller)
    {
       this.controller = controller;
    }
    

    
    /**
     * Process a combinationEntered transition
     */
    public void combinationEntered()
    {
       controller.changeState(Closed.enter(controller));
    }
    


    /**
     * Enter this State
     *
     * Specifically, construct an instance if necessary and perform any
     * necessary operations
     *
     * @param controller   The Controller to perform operations on
     * @return             The (singleton) instance of this State
     */
    public static State enter(Controller controller)
    {
       if (instance == null) instance = new AwaitingCombination(controller);

       controller.reset();       
       return instance;
    }


    /**
     * Process an errorEntered transition
     */
    public void errorEntered()
    {
       controller.changeState(Locked.enter(controller));
    }
    
    
}
