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.
21 lines
511 B
21 lines
511 B
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();
|
|
}
|
|
}
|
|
|