Using Strategy Pattern in Java

Publicado el: 09 septiembre 2020
en el canal de: Improve Your Programming skills
47
5

The strategy design pattern (behavioral design pattern) allows you to change the behavior
of an application that does not violate the open/closed principle (OCP)
By defining a family of algorithms, encapsulate each one, and make them
interchangeable, it makes the algorithm vary independently
from the application that use it.
Example: Build a soccer game that allow a user play with a computer
Steps:
1. Create an IComputerPlayer interface
2. Create 3 classes: EasyComputerPlayer, MediumComputerPlayer and HardComputerPlayer that implement the IComputerPlayer interface
3. Create a SoccerGame class that allow user to play soccer with one of 3 ComputerPlayer level above
4. Create a demo program that uses the SoccerGame class


En esta página del sitio puede ver el video en línea Using Strategy Pattern in Java de Duración hora minuto segunda en buena calidad , que subió el usuario Improve Your Programming skills 09 septiembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 47 veces y le gustó 5 a los espectadores. Disfruta viendo!