|
|
@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Beverage
|
|
|
|
|
|
|
|
# шаблонный метод
|
|
|
|
|
|
|
|
def prepare
|
|
|
|
|
|
|
|
boil_water
|
|
|
|
|
|
|
|
brew
|
|
|
|
|
|
|
|
pour_in_cup
|
|
|
|
|
|
|
|
add_condiments
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# общие методы
|
|
|
|
|
|
|
|
def boil_water
|
|
|
|
|
|
|
|
puts "Кипячение воды..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pour_in_cup
|
|
|
|
|
|
|
|
puts "Наливание в чашку..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def brew
|
|
|
|
|
|
|
|
raise NotImplementedError, "Метод 'brew' должен быть определён"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_condiments
|
|
|
|
|
|
|
|
raise NotImplementedError, "Метод 'add_condiments' должен быть определён"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Tea < Beverage
|
|
|
|
|
|
|
|
def brew
|
|
|
|
|
|
|
|
puts "Заваривание чая..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_condiments
|
|
|
|
|
|
|
|
puts "Добавление лимона..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Coffee < Beverage
|
|
|
|
|
|
|
|
def brew
|
|
|
|
|
|
|
|
puts "Заваривание кофе..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_condiments
|
|
|
|
|
|
|
|
puts "Добавление сахара и молока..."
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
puts "☕️Приготовление чая:"
|
|
|
|
|
|
|
|
tea = Tea.new
|
|
|
|
|
|
|
|
tea.prepare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
puts "\n☕️Приготовление кофе:"
|
|
|
|
|
|
|
|
coffee = Coffee.new
|
|
|
|
|
|
|
|
coffee.prepare
|