예제 #1
0
        public ArrayList Search(MandolinSpec searchGuitar)
        {
            ArrayList matchingMandolin = new ArrayList();

            foreach (var instrument in _inventory)
            {
                Mandolin mandolin = (Mandolin)instrument;
                if (mandolin.Spec.Matches(searchGuitar))
                {
                    matchingMandolin.Add(mandolin);
                }
            }
            return(matchingMandolin);
        }
예제 #2
0
        public void AddInstrument(String serialNumber, double price, InstrumentSpec spec)
        {
            Instrument instrument = null;

            if (spec is GuitarSpec)
            {
                instrument = new Guitar(serialNumber, price, (GuitarSpec)spec);
            }
            else if (spec is MandolinSpec)
            {
                instrument = new Mandolin(serialNumber, price, (MandolinSpec)spec);
            }
            _inventory.Add(instrument);
        }