turnstyle.java
来自「著名的uncle Bob的Agile software development的」· Java 代码 · 共 65 行
JAVA
65 行
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 + =
减小字号Ctrl + -
显示快捷键?