#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;
/**
*
* Strategy (DragonSlayingStrategy) encapsulates an algorithm. The containing
* 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();
}
}
package com.iluwatar.strategy;
/**
*
* Strategy ({@link DragonSlayingStrategy}) encapsulates an algorithm. The containing
* object ({@link DragonSlayer}) can alter its behavior by changing its strategy.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
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

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