Exemple #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);
        }
Exemple #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);
     }
 }
Exemple #3
0
        public List <Mandolin> Search(MandolinSpec searchGuitar)
        {
            List <Mandolin> matchingmandoline = new List <Mandolin>();

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