strategy
This commit is contained in:
parent
bbc83bd593
commit
6e01bc4695
|
@ -3,15 +3,15 @@ abstract class CoffeeStrategy {
|
|||
}
|
||||
|
||||
class AmericanoStrategy implements CoffeeStrategy {
|
||||
String announce(String roast) => "an Americano with $roast beans";
|
||||
String announce(String roast) => "Американо с $roast бобами";
|
||||
}
|
||||
|
||||
class DripStrategy implements CoffeeStrategy {
|
||||
String announce(String roast) => "a drip coffee with $roast beans";
|
||||
class LatteStrategy implements CoffeeStrategy {
|
||||
String announce(String roast) => "Латте с $roast бобами";
|
||||
}
|
||||
|
||||
class MochaFrappuccinoStrategy implements CoffeeStrategy {
|
||||
String announce(String roast) => "a delicious mocha frappuccion with $roast beans";
|
||||
class EspressoStrategy implements CoffeeStrategy {
|
||||
String announce(String roast) => "Эспрессо с $roast бобами";
|
||||
}
|
||||
|
||||
class CoffeeDrinker {
|
||||
|
@ -22,29 +22,23 @@ class CoffeeDrinker {
|
|||
|
||||
void main() {
|
||||
var americano = AmericanoStrategy();
|
||||
var drip = DripStrategy();
|
||||
var mocha = MochaFrappuccinoStrategy();
|
||||
var latte = LatteStrategy();
|
||||
var espresso = EspressoStrategy();
|
||||
|
||||
var me = CoffeeDrinker("Tyler", drip);
|
||||
var europeanBuddy = CoffeeDrinker("Pieter", americano);
|
||||
var myDaughter = CoffeeDrinker("Joanie", mocha);
|
||||
var p1 = CoffeeDrinker("Андрей", latte);
|
||||
var p2 = CoffeeDrinker("Никита", americano);
|
||||
var p3 = CoffeeDrinker("Олег", espresso);
|
||||
|
||||
final String roastOfTheDay = "Italian";
|
||||
final String roastOfTheDay = "Итальянскими";
|
||||
|
||||
for (var person in [me, europeanBuddy, myDaughter]) {
|
||||
print("Hey ${person.name}, whatcha drinkin' over there?");
|
||||
print("I'm enjoying ${person.preferredDrink.announce(roastOfTheDay)}!\r\n");
|
||||
for (var person in [p1, p2, p3]) {
|
||||
print(
|
||||
"Меня зовут ${person.name}. Я сейчас пью ${person.preferredDrink.announce(roastOfTheDay)}!\r");
|
||||
}
|
||||
|
||||
/*
|
||||
Hey Tyler, whatcha drinkin' over there?
|
||||
I'm enjoying a drip coffee with Italian beans!
|
||||
|
||||
Hey Pieter, whatcha drinkin' over there?
|
||||
I'm enjoying an Americano with Italian beans!
|
||||
|
||||
Hey Joanie, whatcha drinkin' over there?
|
||||
I'm enjoying a delicious mocha frappuccion with Italian beans!
|
||||
Меня зовут Андрей. Я сейчас пью Латте с Итальянскими бобами!
|
||||
Меня зовут Никита. Я сейчас пью Американо с Итальянскими бобами!
|
||||
Меня зовут Олег. Я сейчас пью Эспрессо с Итальянскими бобами!
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue