mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 14:17:46 +00:00
Comments for the strategy example.
This commit is contained in:
1 parent
4debc8eda4
commit
94b289801b
3 files changed
+16
No files matched your search
@@ -1,5 +1,11 @@
|
|||||||
package com.iluwatar;
|
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 class App
|
||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* DragonSlayer uses different strategies to slay the dragon.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class DragonSlayer {
|
public class DragonSlayer {
|
||||||
|
|
||||||
private DragonSlayingStrategy strategy;
|
private DragonSlayingStrategy strategy;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Strategy interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface DragonSlayingStrategy {
|
public interface DragonSlayingStrategy {
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|||||||
Reference in new issue
Block a user