public Guitar(String serialNumber, double price, GuitarSpec guitarSpec) { this.serialNumber = serialNumber; this.price = price; this.spec = guitarSpec; }
public List<Guitar> search(GuitarSpec searchSpec) { List<Guitar> matchingGuitars = new List<Guitar>(); foreach (Guitar guitar in guitars) { var guitarSpec = guitar.getSpec(); if (guitar.getSpec().matches(searchSpec)) matchingGuitars.Add(guitar); } return matchingGuitars; }
public bool matches(GuitarSpec otherSpec) { if (builder != otherSpec.builder) return false; if ((model != null) && (!model.Equals("")) && (!model.ToLower().Equals(otherSpec.model.ToLower()))) return false; if (type != otherSpec.type) return false; // if (numStrings != otherSpec.numStrings) // return false; if (backWood != otherSpec.backWood) return false; if (topWood != otherSpec.topWood) return false; return true; }
public void SearchGuitar() { var whatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC,6, Wood.ALDER, Wood.ALDER); var guitars = inventory.search(whatErinLikes); if (guitars.Count!=0) { foreach (var guitar in guitars) { var guitarSpec = guitar.getSpec(); Debug.WriteLine("Erin, you might like this " + guitarSpec.getBuilder() + " " + guitarSpec.getModel() + " " + guitarSpec.getType() + " guitar:\n " + guitarSpec.getBackWood() + " back and sides,\n " + guitarSpec.getTopWood() + " top.\nYou can have it for only $" + guitar.getPrice() + "!"); } } else { System.Console.WriteLine("Sorry, Erin, we have nothing for you."); } }
public void addGuitar(String serialNumber, double price, GuitarSpec spec) { Guitar guitar = new Guitar(serialNumber, price, spec); guitars.Add(guitar); }