Exemple #1
0
        public Slider GetSlider(char key)
        {
            var slider = _sliders.ContainsKey(key) ? _sliders[key] : null;

            if (slider == null)
            {
                switch (key.ToString().ToUpper())
                {
                case BACON: slider = new BaconMaster(); break;

                case VEGGIE: slider = new Veggie(); break;

                case BBQ: slider = new BBQKing(); break;

                default: throw new Exception($"key: {key} not found");
                }
            }

            slider.OrderId = ++orderId;
            return(slider);
        }
        public Slider GetSlider(char key)
        {
            Slider slider = null;

            if (_sliders.ContainsKey(key)) //If we've already created one of the requested type of slider, just use that.
            {
                slider = _sliders[key];
            }
            else //Otherwise, create a brand new instance of the slider.
            {
                switch (key)
                {
                case 'B': slider = new BaconMaster(); break;

                case 'V': slider = new VeggieSlider(); break;

                case 'Q': slider = new BBQKing(); break;
                }
                _sliders.Add(key, slider);
            }
            return(slider);
        }