Exemplo n.º 1
0
        public static PapersFactory GetPapersFactory()
        {
            if (_instance == null)
            {
                lock (syncLock) {
                    if (_instance == null)
                    {
                        _instance = new DorogobogatoPapersFactory();
                    }
                }
            }

            return(_instance);
        }
Exemplo n.º 2
0
        public static PapersFactory GetPapersFactory()
        {
            if (_instance == null)
            {
                lock (syncLock) {
                    if (_instance == null)
                    {
                        _instance = new CheapPapersFactory();
                    }
                }
            }

            return(_instance);
        }
Exemplo n.º 3
0
        public Papers MakePapers(Participant p)
        {
            PapersFactory appropriate = null;

            foreach (var factory in _factories)
            {
                if (factory.Cost < p.MoneyForPapers)
                {
                    appropriate       = factory;
                    p.MoneyForPapers -= factory.Cost;
                    break;
                }
            }

            if (appropriate == null)
            {
                Console.WriteLine("You got not enough money");
                return(null);
            }
            Console.WriteLine("Here is your papers");
            return(appropriate.CreatePapers(p));
        }