Formatted all files to the same standard

This commit is contained in:
matthew
2014-10-08 13:42:12 +01:00
parent 53a2a8b150
commit 3da9ad5469
151 changed files with 952 additions and 870 deletions

View File

@ -1,24 +1,24 @@
package com.iluwatar;
/**
*
*
* Decorator pattern is more flexible alternative to subclassing. The decorator
* class implements the same interface as the target and uses composition to
* "decorate" calls to the target.
*
*
*/
public class App {
public static void main(String[] args) {
public static void main(String[] args) {
System.out.println("A simple looking troll approaches.");
Hostile troll = new Troll();
troll.attack();
troll.fleeBattle();
System.out.println("A simple looking troll approaches.");
Hostile troll = new Troll();
troll.attack();
troll.fleeBattle();
System.out.println("\nA smart looking troll surprises you.");
Hostile smart = new SmartTroll(new Troll());
smart.attack();
smart.fleeBattle();
}
System.out.println("\nA smart looking troll surprises you.");
Hostile smart = new SmartTroll(new Troll());
smart.attack();
smart.fleeBattle();
}
}

View File

@ -3,6 +3,7 @@ package com.iluwatar;
public interface Hostile {
void attack();
void fleeBattle();
}

View File

@ -7,7 +7,7 @@ public class SmartTroll implements Hostile {
public SmartTroll(Hostile decorated) {
this.decorated = decorated;
}
@Override
public void attack() {
System.out.println("The troll throws a rock at you!");
@ -19,5 +19,5 @@ public class SmartTroll implements Hostile {
System.out.println("The troll calls for help!");
decorated.fleeBattle();
}
}

View File

@ -5,9 +5,9 @@ public class Troll implements Hostile {
public void attack() {
System.out.println("The troll swings at you with a club!");
}
public void fleeBattle() {
System.out.println("The troll shrieks in horror and runs away!");
}
}