-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractFabrika.dart
More file actions
153 lines (117 loc) · 2.96 KB
/
AbstractFabrika.dart
File metadata and controls
153 lines (117 loc) · 2.96 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
abstract class TypeAlcohol {
final String nameAlcohol;
TypeAlcohol(this.nameAlcohol);
void create();
}
abstract class CountryFrom {
final String nameAlcohol;
CountryFrom(this.nameAlcohol);
void create();
}
abstract class JustType {
final String nameAlcohol;
JustType(this.nameAlcohol);
void create();
}
class WiskeyAlcholType extends TypeAlcohol {
WiskeyAlcholType() : super('Wiskey');
@override
void create() {
print('Тип выбраного алкоголя : $nameAlcohol');
}
}
class WiskeyCountryFrom extends CountryFrom {
WiskeyCountryFrom() : super('Usa');
@override
void create() {
print('Виски привезён из : $nameAlcohol');
}
}
class WiskeyJustType extends JustType {
WiskeyJustType () : super('Burbon');
@override
void create() {
print('В классификации это : $nameAlcohol');
}
}
class Cognac extends TypeAlcohol {
Cognac() : super ('Коньяк');
@override
void create(){
print('Тип выбранного алкоголя : $nameAlcohol');
}
}
class CognacCountryFrom extends CountryFrom {
CognacCountryFrom() : super ('France');
@override
void create(){
print('Коньяк привезён из : $nameAlcohol');
}
}
class CognacJustType extends JustType {
CognacJustType() : super('Коньяк');
@override
void create() {
print('В классификации это : $nameAlcohol');
}
}
abstract class AlcoholAbstractFactory {
TypeAlcohol getTypeAlcohol();
CountryFrom getCountryFrom();
JustType getJustType();
}
class WiskeyAlcoholFactory implements AlcoholAbstractFactory {
@override
TypeAlcohol getTypeAlcohol() {
return WiskeyAlcholType();
}
@override
CountryFrom getCountryFrom() {
return WiskeyCountryFrom();
}
@override
JustType getJustType() {
return WiskeyJustType();
}
}
class CognacAlcoholFactory implements AlcoholAbstractFactory {
@override
TypeAlcohol getTypeAlcohol() {
return Cognac();
}
@override
CountryFrom getCountryFrom() {
return CognacCountryFrom();
}
@override
JustType getJustType() {
return CognacJustType();
}
}
enum TypeThis {Wiskey, Cognac}
class Application {
final AlcoholAbstractFactory guiFactory;
Application(this.guiFactory);
void createGui(){
guiFactory.getTypeAlcohol().create();
guiFactory.getCountryFrom().create();
guiFactory.getJustType().create();
}
}
class AlcoholFactoryThis {
static AlcoholAbstractFactory factory(TypeThis tupe) {
switch (tupe) {
case TypeThis.Wiskey:
return WiskeyAlcoholFactory();
case TypeThis.Cognac : return CognacAlcoholFactory();
default:
throw ArgumentError();
}
}
}
void main(){
var tupe = TypeThis.Cognac;
var guifactory = AlcoholFactoryThis.factory(tupe);
var app = Application(guifactory);
app.createGui();
}