-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaceSetting.java
58 lines (58 loc) · 1.13 KB
/
PlaceSetting.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Совмещение композиции и наследованния
import static net.slav.util.Print.*;
class Plate{
Plate(int i){
print("Конструктор Plate");
}
}
class DinnerPlate extends Plate{
DinnerPlate(int i){
super(i);
print("Конструктор DinnerPlate");
}
}
class Utensil{
Utensil(int i){
print("Конструктор Utensil");
}
}
class Spoon extends Utensil{
Spoon(int i){
super(i);
print("Конструктор Spoon");
}
}
class Fork extends Utensil{
Fork(int i){
super(i);
print("Конструктор Fork");
}
}
class Knife extends Utensil{
Knife(int i){
super(i);
print("Конструктор Knife");
}
}
class Custom{
Custom(int i){
print("Конструктор Custom");
}
}
public class PlaceSetting extends Custom{
private Spoon sp;
private Fork frk;
private Knife kn;
private DinnerPlate pl;
public PlaceSetting(int i){
super(i);
sp = new Spoon(i);
frk = new Fork(i);
kn = new Knife(i);
pl =new DinnerPlate(i);
print("Конструктор PlaceSetting");
}
public static void main(String[] args){
PlaceSetting x = new PlaceSetting(9);
}
}