public static void testErin() { // Set up Rick's guitar inventory Inventory inventory = new Inventory(); initializeInventory(inventory); GuitarSpec whatErinLikes = new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6); List<Guitar> guitars = inventory.search(whatErinLikes); if (guitars.Count > 0) { string msgSuccess = "Erin, you might like these guitars: "; foreach (Guitar guitar in guitars) { GuitarSpec spec = guitar.spec; msgSuccess += "\nWe have a " + Enumerations.GetEnumDescription(spec.builder) + " " + spec.model + " " + Enumerations.GetEnumDescription(spec.type) + " guitar:\n " + Enumerations.GetEnumDescription(spec.backWood) + " back and sides,\n " + Enumerations.GetEnumDescription(spec.topWood) + " top.\nYou can have it for only $" + guitar.price + "!\n ----"; } Console.WriteLine(msgSuccess); Console.ReadKey(); } else { string msgFail = "Sorry, Erin, we have nothing for you."; Console.WriteLine(msgFail); Console.ReadKey(); } }
public static void testErin() { // Set up Rick's guitar inventory Inventory inventory = new Inventory(); initializeInventory(inventory); Guitar whatErinLikes = new Guitar("", 0, Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder); List <Guitar> guitars = inventory.search(whatErinLikes); if (guitars.Count > 0) { string msgSuccess = "Erin, you might like these guitars: "; foreach (Guitar guitar in guitars) { msgSuccess += "\nWe have a " + Enumerations.GetEnumDescription(guitar.builder) + " " + guitar.model + " " + Enumerations.GetEnumDescription(guitar.type) + " guitar:\n " + Enumerations.GetEnumDescription(guitar.backWood) + " back and sides,\n " + Enumerations.GetEnumDescription(guitar.topWood) + " top.\nYou can have it for only $" + guitar.price + "!\n ----"; } Console.WriteLine(msgSuccess); Console.ReadKey(); } else { string msgFail = "Sorry, Erin, we have nothing for you."; Console.WriteLine(msgFail); Console.ReadKey(); } }
public static void testErin() { // Set up Rick's guitar inventory Inventory inventory = new Inventory(); initializeInventory(inventory); Guitar whatErinLikes = new Guitar("", 0, "Fender", "Stratocastor", "electric", "Alder", "Alder"); Guitar guitar = inventory.search(whatErinLikes); if (guitar != null) { string msgSuccess = "Erin, you might like this " + guitar.builder + " " + guitar.model + " " + guitar.type + " guitar:\n " + guitar.backWood + " back and sides,\n " + guitar.topWood + " top.\nYou can have it for only $" + guitar.price + "!"; Console.WriteLine(msgSuccess); Console.ReadKey(); } else { string msgFail = "Sorry, Erin, we have nothing for you."; Console.WriteLine(msgFail); Console.ReadKey(); } }
static void Main(string[] args) { Inventory inventory = new Inventory(); initializeInvetory(inventory); GuitarSpec whatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, Wood.MAPLE, Wood.CEDAR); List <Guitar> matchingGuitars = inventory.search(whatErinLikes); if (matchingGuitars != null) { Console.WriteLine("Erin, you might like these guitars :"); foreach (Guitar guitar in matchingGuitars) // we can use foreach instead of IEnumerator to loop thorugh the collection { GuitarSpec spec = guitar.getSpec(); Console.WriteLine(" We have a " + spec.getBuilder() + " " + spec.getModel() + " " + spec.getType() + " guitar : \n " + spec.getBackWood() + " back and sides, \n " + spec.getTopWood() + " top. \nYou can have it only for $" + guitar.getPrice() + " ! "); } } else { Console.WriteLine("Sorry, Erin, we have nothing for you."); } }