public Guitar(string serialNumber, double price, GuitarSpec spec) : base(serialNumber, price) { this.spec = spec; }
public Guitar(string serialNumber, double price, GuitarSpec spec) : base(serialNumber, price, spec) { }
public static void testInstrumentSearch() { // Set up Rick's instrument inventory Inventory inventory = new Inventory(); initializeInventory(inventory); GuitarSpec whatErinLikes = new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6); findInstrument("Erin", whatErinLikes, inventory); MandolinSpec whatPhilLikes = new MandolinSpec(Builder.Fender, "Stratocastor", Type.acoustic, Wood.Alder, Wood.Alder, Style.A); findInstrument("Phil", whatPhilLikes, inventory); }
public List<Guitar> search(GuitarSpec searchSpec) { List<Guitar> matchingGuitars = new List<Guitar>(); for (int i = 0; i < _inventory.Count; i++) { if (!(_inventory[i] is Guitar)) { continue; } Guitar guitar = (Guitar)_inventory[i]; if (guitar.spec.matches(searchSpec)) { matchingGuitars.Add(guitar); } } return matchingGuitars; }
public List <Guitar> search(GuitarSpec searchSpec) { List <Guitar> matchingGuitars = new List <Guitar>(); for (int i = 0; i < _inventory.Count; i++) { if (!(_inventory[i] is Guitar)) { continue; } Guitar guitar = (Guitar)_inventory[i]; if (guitar.spec.matches(searchSpec)) { matchingGuitars.Add(guitar); } } return(matchingGuitars); }
public override bool matches(InstrumentSpec spec) { if (!base.matches(spec)) { return(false); } if (!(spec is GuitarSpec)) { return(false); } GuitarSpec guitarSpec = (GuitarSpec)spec; if (!stringsMatch(model, guitarSpec.model)) { return(false); } return(true); }