You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
511 B
22 lines
511 B
3 years ago
|
package patronStrategy;
|
||
|
|
||
|
public class Main {
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
|
||
|
//instanciamos la estrategia A
|
||
|
Estrategia estrategiaInicial = new EstrategiaA();
|
||
|
//se la asignamos al contexto
|
||
|
Contexto contexto = new Contexto(estrategiaInicial);
|
||
|
|
||
|
contexto.ejecutarMetodoEstrategico();
|
||
|
|
||
|
//instancias la estrategia B
|
||
|
Estrategia otraEstrategia = new EstrategiaB();
|
||
|
//se la asignamos al contexto
|
||
|
contexto.setEstrategia(otraEstrategia);
|
||
|
|
||
|
contexto.ejecutarMetodoEstrategico();
|
||
|
}
|
||
|
}
|