-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpaceShipDelegation.java
43 lines (42 loc) · 1.03 KB
/
SpaceShipDelegation.java
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
41
42
43
class SpaceShipControls{
void up(int velocity){}
void down(int velocity){}
void left(int velocity){}
void right(int velocity){}
void forward(int velocity){System.out.println("OK");}
void back(int velocity){}
void turboBoost(){}
}
public class SpaceShipDelegation{
private String name;
private SpaceShipControls controls = new SpaceShipControls();
public SpaceShipDelegation(String name){
this.name=name;
}
//Делегированные методы
public void back(int velocity){
controls.back(velocity);
}
public void down(int velocity){
controls.down(velocity);
}
public void forward(int veloсity){
controls.forward(veloсity);
}
public void left(int veloсity){
controls.left(veloсity);
}
public void right(int veloсity){
controls.right(veloсity);
}
public void turboBoost(){
controls.turboBoost();
}
public void up(int veloсity){
controls.up(veloсity);
}
public static void main(String[] args){
SpaceShipDelegation protector=new SpaceShipDelegation("NSEA Protector");
protector.forward(100);
}
}