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); }
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); }
public Guitar(String serialNumber, double price, GuitarSpec spec) : base(serialNumber, price, spec) { }