예제 #1
0
        public IEnumerable <Guitar> Search(GuitarSpec searchSpec)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            foreach (Instrument instrument in inventory)
            {
                if (!(instrument is Guitar))
                {
                    continue;
                }

                Guitar guitar = instrument as Guitar;
                if (guitar.Spec.Matches(searchSpec))
                {
                    matchingGuitars.Add(guitar);
                }
            }

            return(matchingGuitars);
        }
예제 #2
0
        public override bool Matches(InstrumentSpec matchSpec)
        {
            if (!base.Matches(matchSpec))
            {
                return(false);
            }

            GuitarSpec guitarMatchSpec = matchSpec as GuitarSpec;

            if (guitarMatchSpec == null)
            {
                return(false);
            }

            if (guitarMatchSpec.NumStrings != NumStrings)
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
 public Guitar(String serialNumber, double price, GuitarSpec spec)
     : base(serialNumber, price, spec)
 {
 }