/**
 * The Opened State (for a garage door Controller)
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Opened extends State
{
    private        Controller           controller;
    private static Opened               instance;
    

    /**
     * Explicit Value Constuctor 
     * [used by the enter() method]
     *
     * @param controller   The Controller to use
     */
    private Opened(Controller controller)
    {
       this.controller = controller;
    }
    

    
    /**
     * Process a close transition
     */
    public void close()
    {
       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 Opened(controller);

       return instance;
    }
}
