-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContext.java
More file actions
36 lines (34 loc) · 988 Bytes
/
Context.java
File metadata and controls
36 lines (34 loc) · 988 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
26
27
28
29
30
31
32
33
34
35
36
package design.state;
public class Context {
//定义出所有的电梯状态
public final static OpenningState openningState =
new OpenningState();
public final static ClosingState closingState =
new ClosingState();
public final static RunningState runningState =
new RunningState();
public final static StoppingState stoppingState =
new StoppingState();
//定义一个当前的电梯状态
private LiftState liftState;
public LiftState getLiftState() {
return liftState;
}
public void setLiftState(LiftState liftState) {
this.liftState = liftState;
this.liftState.setContext(this);
// this.liftState.stop();
}
public void open() {
this.liftState.open();
}
public void close() {
this.liftState.close();
}
public void run() {
this.liftState.run();
}
public void stop() {
this.liftState.stop();
}
}