-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
69 lines (48 loc) · 1.87 KB
/
Solution.java
File metadata and controls
69 lines (48 loc) · 1.87 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//I made known to them your name, and will make it known; that the love with which you loved me may be in them, and I in them. (John 17:26)
package com.javarush.task.task18.task1811;
/*
Wrapper (Decorator)
*/
public class Solution {
public static void main(String[] args) {
new Thread(new DecoratorRunnableImpl(new DecoratorMyRunnableImpl(new RunnableImpl()))).start();
}
public static class RunnableImpl implements Runnable {
@Override
public void run() {
System.out.println("RunnableImpl body");
}
}
public static class DecoratorRunnableImpl implements Runnable {
private Runnable component;
public DecoratorRunnableImpl(Runnable component) {
this.component = component;
}
@Override
public void run() {
System.out.print("DecoratorRunnableImpl body ");
component.run();
}
}
public static class DecoratorMyRunnableImpl implements Runnable {
private Runnable component;
public DecoratorMyRunnableImpl(Runnable component) {
this.component = component;
}
@Override
public void run() {
System.out.print("DecoratorMyRunnableImpl body ");
component.run();
}
}
}
/*
Wrapper (Decorator)
Разберись, что делает программа.
Аналогично классу DecoratorRunnableImpl создай класс DecoratorMyRunnableImpl.
Требования:
1. Создай класс DecoratorMyRunnableImpl, аналогичный DecoratorRunnableImpl.
2. После запуска, каждый класс должен вывести в консоль "'Имя класса' body".
3. Классы RunnableImpl и DecoratorRunnableImpl изменять нельзя.
4. Метод main изменять нельзя.
*/