public static CzechPresident GetCurrentPresident()
        {
            if (_instance == null)
            {
                _instance = new CzechPresident();
                _instance.ElectionTime = DateTime.Now;
            }

            return(_instance);
        }
예제 #2
0
        static void Main(string[] args)
        {
            WriteLine("First president:");
            var president = CzechPresident.GetCurrentPresident();

            Thread.Sleep(1500);
            WriteLine(president.IntroduceYourself());

            WriteLine("\nSecond president:");
            Thread.Sleep(2500);
            var otherPresident = CzechPresident.GetCurrentPresident();

            WriteLine(otherPresident.IntroduceYourself());

            WriteLine("\nAre they the same?");
            WriteLine(president.Equals(otherPresident));

            ReadKey();
        }