Beispiel #1
0
        static void Main(string[] args)
        {
            Singleton player_1 = Singleton.GetInstance;

            player_1.Message("Jogador 1: A bola está comigo no meio do campo");

            Singleton player_2 = Singleton.GetInstance;

            player_2.Message("Jogador 2: recebeu a bola");

            Singleton player_3 = Singleton.GetInstance;

            player_3.Message("Jogador 3: Recebeu o lançamento na linha de fundo");

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Singleton msg1 = Singleton.GetInstance;

            msg1.Message("1st call - It's being instantiated, because it's the first time it's being called!");

            Singleton msg2 = Singleton.GetInstance;

            msg2.Message("2nd call - Not instantiated, because it was already done on the first call!");

            Singleton msg3 = Singleton.GetInstance;

            msg3.Message("3rd call - Not instantiated, because it was already done on the first call!");

            Console.ReadKey();
        }