static void Main(string[] args) { FindGuitarTester mainCls = new FindGuitarTester(); Inventory inventory = new Inventory(); mainCls.initalizeInventory(inventory); GuitarSpec whatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, 6, Wood.ALDER, Wood.ALDER); List <object> machingGuitars = inventory.search(whatErinLikes); if (!machingGuitars.Equals(null)) { Console.WriteLine("Erin, you might like these guitars:"); int index = 0; foreach (var i in machingGuitars) { Guitar guitar = (Guitar)machingGuitars[index]; GuitarSpec spec = guitar.GetSpec(); Console.WriteLine("We have a " + spec.getBuilder().ToString().ToLower() + " " + spec.getModel() + " " + spec.getType().ToString().ToLower() + " guitar:\n" + spec.getBackWood().ToString().ToLower() + " back and sides,\n" + spec.getTopWood().ToString().ToLower() + " top.\n You can have it for only $" + guitar.getPrice() + "!\n"); index++; } } else { Console.WriteLine("Sorry, Erin, we have nothing for you."); } }
public Guitar getGuitar(String serialNumber) { int index = 0; foreach (var i in guitars) { Guitar guitar = (Guitar)guitars[index]; if (guitar.getSerialNumber().Equals(serialNumber)) { return(guitar); } index++; } return(null); }
public List <object> search(GuitarSpec searchSpec) { List <object> matchingGuitars = new List <object>(); int index = 0; foreach (var i in guitars) { Guitar guitar = (Guitar)guitars[index]; if (guitar.GetSpec().matches(searchSpec)) { matchingGuitars.Add(guitar); } index++; } return(matchingGuitars); }
public void addGuitar(String serialNumber, double price, GuitarSpec spec) { Guitar guitar = new Guitar(serialNumber, price, spec); guitars.Add(guitar); }