📄 turnstyle.java
字号:
public class Turnstyle
{
private static TurnstyleState lockedState = new LockedTurnstyleState();
private static TurnstyleState unlockedState = new UnlockedTurnstyleState();
private TurnstyleController turnstyleController;
private TurnstyleState state = lockedState;
public Turnstyle(TurnstyleController action)
{
turnstyleController = action;
}
public void coin()
{
state.coin(this);
}
public void pass()
{
state.pass(this);
}
public void setLocked()
{
state = lockedState;
}
public void setUnlocked()
{
state = unlockedState;
}
public boolean isLocked()
{
return state == lockedState;
}
public boolean isUnlocked()
{
return state == unlockedState;
}
void thankyou()
{
turnstyleController.thankyou();
}
void alarm()
{
turnstyleController.alarm();
}
void lock()
{
turnstyleController.lock();
}
void unlock()
{
turnstyleController.unlock();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -