Created
September 27, 2012 13:48
-
-
Save hvitorino/3794103 to your computer and use it in GitHub Desktop.
Strategy Pattern
This file contains hidden or 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
| using System; | |
| namespace Bolar | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Bora.BolarUmBong.MandaVer(); | |
| Bora.BolarUmFino.MandaVer(); | |
| Console.ReadKey(); | |
| } | |
| public class Bora | |
| { | |
| private static Bora singleton; | |
| static Bora() | |
| { | |
| singleton = new Bora(); | |
| } | |
| private BoladorDeBong boladorDeBong; | |
| private BoladorDeFino boladorDeFino; | |
| public Bora() | |
| { | |
| boladorDeBong = new BoladorDeBong(); | |
| boladorDeFino = new BoladorDeFino(); | |
| } | |
| public static BoladorDeBong BolarUmBong | |
| { | |
| get { return singleton.boladorDeBong; } | |
| } | |
| public static BoladorDeFino BolarUmFino | |
| { | |
| get { return singleton.boladorDeFino; } | |
| } | |
| } | |
| public abstract class Bolador | |
| { | |
| public abstract void MandaVer(); | |
| } | |
| public class BoladorDeBong : Bolador | |
| { | |
| public override void MandaVer() | |
| { | |
| Console.WriteLine("BONG: ########### ~~~~~~~~"); | |
| } | |
| } | |
| public class BoladorDeFino : Bolador | |
| { | |
| public override void MandaVer() | |
| { | |
| Console.WriteLine("FINO: ----- ~~~"); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment