forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDayState.java
More file actions
25 lines (24 loc) · 735 Bytes
/
DayState.java
File metadata and controls
25 lines (24 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class DayState implements State {
private static DayState instance = new DayState();
private DayState() {}
public static DayState getInstance() {
return DayState.instance;
}
public void doClock(Context context, int hour) {
if (hour < 9 || 17 <= hour) {
context.changeState(NightState.getInstance());
}
}
public void doUse(Context context) {
context.recordLog("Use (daytime)");
}
public void doAlarm(Context context) {
context.callSecurityCenter("Alerm (daytime)");
}
public void doPhone(Context context) {
context.callSecurityCenter("Phone (daytime)");
}
public String toString() {
return "DAYTIME";
}
}