forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemyRobotAdapter.java
More file actions
40 lines (22 loc) · 722 Bytes
/
EnemyRobotAdapter.java
File metadata and controls
40 lines (22 loc) · 722 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
37
38
39
40
// The Adapter must provide an alternative action for
// the the methods that need to be used because
// EnemyAttacker was implemented.
// This adapter does this by containing an object
// of the same type as the Adaptee (EnemyRobot)
// All calls to EnemyAttacker methods are sent
// instead to methods used by EnemyRobot
public class EnemyRobotAdapter implements EnemyAttacker{
EnemyRobot theRobot;
public EnemyRobotAdapter(EnemyRobot newRobot){
theRobot = newRobot;
}
public void fireWeapon() {
theRobot.smashWithHands();
}
public void driveForward() {
theRobot.walkForward();
}
public void assignDriver(String driverName) {
theRobot.reactToHuman(driverName);
}
}