コード例 #1
0
 public static Singleton_P GiveInstance()
 {
     if (m_instance == null)
     {
         m_instance = new Singleton_P();
     }
     return(m_instance);
 }
コード例 #2
0
        public void MainTesting()
        {
            int testVar;

            System.Console.WriteLine("Presupun ca asa se face");
            Singleton_P singleton_P = Singleton_P.GiveInstance();
            Singleton_P anotherTry  = Singleton_P.GiveInstance();

            testVar = singleton_P.giveSomeMaths();
            System.Console.Write(testVar);
            testVar = anotherTry.giveSomeMaths();
            System.Console.Write(testVar);
            bool checkMyWord = Algorithms.VerifyIfUnique("abcdfh");

            System.Console.WriteLine(checkMyWord);
            System.Console.WriteLine("Awaiting input");
            System.Console.WriteLine(Operations.addNumbers(7, 1));
            Operations.printMessage("practice makes perfect son!");
            Notifier     centralPriceUnit = new Notifier();
            List <Shops> ShopsList        = new List <Shops>();

            for (int i = 0; i < 5; i++)
            {
                ShopsList.Add(new Shops());
            }
            ShopsList.ElementAt(0).Name = "Profi";
            ShopsList.ElementAt(1).Name = "Lidl";
            ShopsList.ElementAt(2).Name = "ABC";
            ShopsList.ElementAt(3).Name = "Auchan";
            ShopsList.ElementAt(4).Name = "Jumbo";

            foreach (var ob in ShopsList)
            {
                centralPriceUnit.registerObserver(ob);
            }
            centralPriceUnit.updatePrice(722);

            Bar     bar       = new Bar();
            Magazin magazin   = new Magazin();
            Client  client    = new Client(bar);
            Client  altClient = new Client(magazin);

            client.Request();
            altClient.Request();
            System.Console.ReadLine();
        }