This commit is contained in:
Морозов Андрей 2022-03-29 02:30:58 +04:00
parent bbc83bd593
commit 6e01bc4695
1 changed files with 17 additions and 23 deletions

View File

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