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,22 +1,22 @@
package com.iluwatar;
/**
*
*
* Strategy (DragonSlayingStrategy) encapsulates the algorithm to use. The
* object (DragonSlayer) can alter its behavior by changing its strategy.
*
*
*/
public class App {
public static void main(String[] args) {
System.out.println("Green dragon spotted ahead!");
DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
dragonSlayer.goToBattle();
System.out.println("Red dragon emerges.");
dragonSlayer.changeStrategy(new ProjectileStrategy());
dragonSlayer.goToBattle();
System.out.println("Black dragon lands before you.");
dragonSlayer.changeStrategy(new SpellStrategy());
dragonSlayer.goToBattle();
}
public static void main(String[] args) {
System.out.println("Green dragon spotted ahead!");
DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
dragonSlayer.goToBattle();
System.out.println("Red dragon emerges.");
dragonSlayer.changeStrategy(new ProjectileStrategy());
dragonSlayer.goToBattle();
System.out.println("Black dragon lands before you.");
dragonSlayer.changeStrategy(new SpellStrategy());
dragonSlayer.goToBattle();
}
}

View File

@ -3,7 +3,7 @@ package com.iluwatar;
/**
*
* DragonSlayer uses different strategies to slay the dragon.
*
*
*/
public class DragonSlayer {
@ -16,7 +16,7 @@ public class DragonSlayer {
public void changeStrategy(DragonSlayingStrategy strategy) {
this.strategy = strategy;
}
public void goToBattle() {
strategy.execute();
}

View File

@ -3,10 +3,10 @@ package com.iluwatar;
/**
*
* Strategy interface.
*
*
*/
public interface DragonSlayingStrategy {
void execute();
}

View File

@ -4,7 +4,8 @@ public class ProjectileStrategy implements DragonSlayingStrategy {
@Override
public void execute() {
System.out.println("You shoot the dragon with the magical crossbow and it falls dead on the ground!");
System.out
.println("You shoot the dragon with the magical crossbow and it falls dead on the ground!");
}
}

View File

@ -4,7 +4,8 @@ public class SpellStrategy implements DragonSlayingStrategy {
@Override
public void execute() {
System.out.println("You cast the spell of disintegration and the dragon vaporizes in a pile of dust!");
System.out
.println("You cast the spell of disintegration and the dragon vaporizes in a pile of dust!");
}
}