Last active
November 16, 2019 16:12
-
-
Save diedona/7325f7fc8e6376a04453e9c23df7bb0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private static Dictionary<Comunicacao, IComunicacao > _comunicadores = | |
new Dictionary<Comunicacao, IComunicacao>() | |
{ | |
{Comunicacao.EMAIL, new ComunicacaoPorEmail() }, | |
{Comunicacao.SMS, new ComunicacaoPorSMS() }, | |
{Comunicacao.SinalDeFumaca, new ComunicacaoPorSinalDeFumaca() } | |
}; | |
static void Main(string[] args) | |
{ | |
PersonService personService = new PersonService(); | |
var pessoas = personService.CarregarPessoas(); | |
foreach (var pessoa in pessoas) | |
{ | |
// recupera a estratégia concreta de comunicação do dicionário | |
personService.DefinirEstrategia(_comunicadores[pessoa.ComunicacaoPreferida]); | |
personService.EnviarComunicacao(pessoa, new Mensagem("EAE", "Td bão?", false)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment