We’re on an encapsulation roll; we’ve encapsulated object creation, method invocation, complex interfaces, ducks, pizzas...what could be next? We’re going to get down to encapsulating pieces of algorithms so that subclasses can hook themselves right into a computation anytime they want. We’re even going to learn about a design principle inspired by Hollywood.
Some people can’t live without their coffee; some people can’t live without their tea. The common ingredient? Caffeine, of course!
But there’s more; tea and coffee are made in very similar ways. Let’s check it out:
Let’s play “coding barista” and write some code for creating coffee and tea.
Here’s the coffee: