コード例 #1
0
        public PastaFactory(string comandOrder)
        {
            _sliders = new Dictionary <char, PastaModel>();

            char[] chars = comandOrder.ToCharArray();
            orderTotal = 0;
            foreach (char c in chars)
            {
                orderTotal++;
                PastaModel character = GetPasta(c);
                character.Display(orderTotal);
            }
        }
コード例 #2
0
        public PastaModel GetPasta(char key)
        {
            PastaModel pasta = null;

            if (_sliders.ContainsKey(key))
            {
                pasta = _sliders[key];
            }
            else
            {
                switch (key)
                {
                case 'A': pasta = new Carbonara(); break;

                case 'R': pasta = new CrockPotSpaghetti(); break;

                case 'S': pasta = new ShrimpFettuccineAlfredo(); break;
                }
                _sliders.Add(key, pasta);
            }
            return(pasta);
        }