package cn.bunny.pattern15.state;

import lombok.Getter;

@Getter
public class Lift {
    // 开门状态
    public static LiftState OPEN_STATE = new OpeningLiftState();
    // 关门状态
    public static LiftState CLOSE_STATE = new ClosingLiftState();
    // 运行状态
    public static LiftState RUNNING_STATE = new RunningLiftState();
    // 停止状态
    public static LiftState STOPPING_STATE = new StoppingLiftState();

    // 当前电梯状态
    private LiftState currentLiftState;

    public void setCurrentLiftState(LiftState currentState) {
        this.currentLiftState = currentState;
        // 执行开门动作
        this.currentLiftState.lift = this;
    }

    public void open() {
        currentLiftState.open();
    }

    public void close() {
        currentLiftState.close();
    }

    public void run() {
        currentLiftState.run();
    }

    public void stop() {
        currentLiftState.stop();
    }
}