-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMove.java
More file actions
29 lines (23 loc) · 695 Bytes
/
Move.java
File metadata and controls
29 lines (23 loc) · 695 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
public class Move extends Action {
private String moveFrom;
private String moveTo;
public Move(String from, String to){
this.operatorName = "MOVE";
this.moveFrom = from;
this.moveTo = to;
}
public boolean checkPreconditions(WorldState worldState) {
if(!worldState.isMonkeyAt(moveFrom)){
return false;
}
if(!worldState.isMonkeyHeight(WorldState.HEIGHT_LOW)){
return false;
}
return true;
}
public WorldState applyPostconditions(WorldState worldState) {
//create and return a new WorldState
//with the monkey’s updated location
return null;
}
}