Загрузил(а) файлы в ''
This commit is contained in:
parent
f43e9fcbe5
commit
605e39e09e
|
@ -2,15 +2,15 @@ abstract class Drinkable {
|
||||||
void pour();
|
void pour();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Beer implements Drinkable {
|
class Lemonade implements Drinkable {
|
||||||
void pour() {
|
void pour() {
|
||||||
print("Pouring a delicious beer!");
|
print("Пью холодный лемонад!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Coffee implements Drinkable {
|
class Coffee implements Drinkable {
|
||||||
void pour() {
|
void pour() {
|
||||||
print("Pouring a refreshing coffee!");
|
print("Пью горячий шоклад!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ abstract class DrinkFactory {
|
||||||
DrinkFactory();
|
DrinkFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Pub implements DrinkFactory {
|
class Cafe implements DrinkFactory {
|
||||||
Drinkable createDrink() {
|
Drinkable createDrink() {
|
||||||
return Beer();
|
return Lemonade();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,24 +32,24 @@ class CoffeeShop implements DrinkFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
var mood = "sleepy";
|
var temperature = "cold";
|
||||||
late DrinkFactory destination;
|
late DrinkFactory destination;
|
||||||
|
|
||||||
switch (mood) {
|
switch (temperature) {
|
||||||
case "sleepy":
|
case "cold":
|
||||||
destination = CoffeeShop();
|
destination = CoffeeShop();
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "warm":
|
||||||
destination = Pub();
|
destination = Cafe();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print("I only have two moods...");
|
print("Мне ни холодно, ни жарко...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var myBeverage = destination.createDrink();
|
var drinkable = destination.createDrink();
|
||||||
myBeverage.pour();
|
drinkable.pour();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Pouring a refreshing coffee!
|
Пью горячий шоклад!
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue