Project shows a simple usage of decorator pattern
This project shows usage of decorator pattern.
The main principle is “Classes should be open for extension but closed for modification”.
Decorators allow user to attach additional responsibilities to an object dynamically.
We define a component class which is extended by concrete component classes and decorator class.
Decorator class is extended by concrete decorators’ classes in which we have a reference to component class.
Project is created with:
To run this project, you need to have jdk
and jre
installed.
Download the src
folder and open it in a command prompt
or terminal
.
Type javac StarbuzzCoffee.java
and press enter to compile.
Type java StarbuzzCoffee
to run program.
This project was created as an exercise from Eric Freeman, Elisabeth Freeman, Bert Bates and Kathy Sierra book “Head First. Wzorce projektowe”.