예제 #1
0
        public void AddInstrument(string serialno, double price, InstrumentSpec spec)
        {
            Instrument instrument = null;

            if (spec is GuitarSpec)
            {
                instrument = new Guitar(serialno, price, (GuitarSpec)spec);
            }
            if (spec is MandolinSpec)
            {
                instrument = new Mandolin(serialno, price, (MandolinSpec)spec);
            }
            _inventory.Add(instrument);
        }
예제 #2
0
 static void ShowData(Instrument instrument)
 {
     if (instrument is Guitar)
     {
         Guitar guitar = (Guitar)instrument;
         Console.WriteLine("\n\tInformation");
         Console.WriteLine("\nserial no:" + guitar.SerialNumber + "\nPrice:" + guitar.Price);
     }
     if (instrument is Mandolin)
     {
         Mandolin mandolin = (Mandolin)instrument;
         Console.WriteLine("\n\tInformation");
         Console.WriteLine("\nserial no:" + mandolin.SerialNumber + "\nPrice:" + mandolin.Price);
     }
 }
예제 #3
0
        public List <Guitar> Search(GuitarSpec searchGuitar)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            for (int i = 0; i < _inventory.Count; i++)
            {
                if (_inventory[i] is Guitar)
                {
                    Guitar G = (Guitar)_inventory[i];
                    if (G.Specification.matches(searchGuitar))
                    {
                        matchingGuitars.Add(G);
                    }
                }
            }
            return(matchingGuitars);
        }