package com.iluwatar.decorator;

/**
 * 
 * Decorator pattern is a more flexible alternative to subclassing. The decorator
 * class implements the same interface as the target and uses composition to
 * "decorate" calls to the target.
 * <p>
 * Using decorator pattern it is possible to change class behavior during
 * runtime, as the example shows.
 * 
 */
public class App {

	/**
	 * Program entry point
	 * @param args command line args
	 */
	public static void main(String[] args) {

		// simple troll
		System.out.println("A simple looking troll approaches.");
		Hostile troll = new Troll();
		troll.attack();
		troll.fleeBattle();
		System.out.printf("Simple troll power %d.\n", troll.getAttackPower());

		// change the behavior of the simple troll by adding a decorator
		System.out.println("\nA smart looking troll surprises you.");
		Hostile smart = new SmartTroll(troll);
		smart.attack();
		smart.fleeBattle();
		System.out.printf("Smart troll power %d.\n", smart.getAttackPower());
	}
}

@@ -36,16 +36,20 @@
 *%0A * %0A *
+ The
  Decorat
@@ -110,17 +110,17 @@
 ng. The 
-d
+D
 ecorator
@@ -235,26 +235,20 @@
 get.
-%0A * %3Cp%3E%0A *
  Using 
-d
+the D
 ecor
@@ -282,20 +282,22 @@
  to 
+%0A * 
 change 
-class
+the
  beh
@@ -306,47 +306,298 @@
 ior 
-during%0A * runtime, as the example shows
+of the class during runtime.%0A * %3Cp%3E%0A * In this example we show how the simple %7B@link Troll%7D first attacks and then%0A * flees the battle. Then we decorate the %7B@link Troll%7D with a %7B@link SmartTroll%7D%0A * and perform the attack again. You can see how the behavior changes after the%0A * decoration
 .%0A *

Improve Decorator Javadoc