#107 JavaDoc for Strategy

This commit is contained in:
Ilkka Seppala 2015-08-21 23:17:25 +03:00
parent ed416ac759
commit 934f99e2a9
2 changed files with 45 additions and 36 deletions

View File

@ -1,22 +1,26 @@
package com.iluwatar.strategy; package com.iluwatar.strategy;
/** /**
* *
* Strategy (DragonSlayingStrategy) encapsulates an algorithm. The containing * Strategy ({@link DragonSlayingStrategy}) encapsulates an algorithm. The containing
* object (DragonSlayer) can alter its behavior by changing its strategy. * object ({@link DragonSlayer}) can alter its behavior by changing its strategy.
* *
*/ */
public class App { public class App {
public static void main(String[] args) { /**
System.out.println("Green dragon spotted ahead!"); * Program entry point
DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy()); * @param args command line args
dragonSlayer.goToBattle(); */
System.out.println("Red dragon emerges."); public static void main(String[] args) {
dragonSlayer.changeStrategy(new ProjectileStrategy()); System.out.println("Green dragon spotted ahead!");
dragonSlayer.goToBattle(); DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
System.out.println("Black dragon lands before you."); dragonSlayer.goToBattle();
dragonSlayer.changeStrategy(new SpellStrategy()); System.out.println("Red dragon emerges.");
dragonSlayer.goToBattle(); dragonSlayer.changeStrategy(new ProjectileStrategy());
} dragonSlayer.goToBattle();
} System.out.println("Black dragon lands before you.");
dragonSlayer.changeStrategy(new SpellStrategy());
dragonSlayer.goToBattle();
}
}

View File

@ -1,14 +1,19 @@
package com.iluwatar.strategy; package com.iluwatar.strategy;
import org.junit.Test; import org.junit.Test;
import com.iluwatar.strategy.App; import com.iluwatar.strategy.App;
public class AppTest { /**
*
@Test * Application test
public void test() { *
String[] args = {}; */
App.main(args); public class AppTest {
}
} @Test
public void test() {
String[] args = {};
App.main(args);
}
}