#107 JavaDoc for Strategy
This commit is contained in:
parent
ed416ac759
commit
934f99e2a9
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user