static void Main(string[] args) { Inventory inventory = new Inventory(); InitializeInventory(inventory); GuitarSpec whatEveLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, Wood.ALDER, Wood.ALDER, 12); List<Guitar> guitars = inventory.Search(whatEveLikes); if (guitars != null) { Console.WriteLine("Mamy w magazynie odpowiednią gitarę: "); foreach (var g in guitars) { GuitarSpec spec = g.Spec; Console.WriteLine(spec.Builder + " model " + spec.Model + " " + spec.Type + " :\n " + spec.BackWood + " - tył i boki,\n " + spec.TopWood + " - góra.\nMożesz ją mieć za " + g.Price + "PLN!\n"); } } else { Console.WriteLine("Przykro mi, nie znalazlem nic dla Ciebie"); } }
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, "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(); } }
private static void initializeInventory(Inventory inventory) { // Add Guitars to the inventory ... inventory.addGuitar("V12345", 0, "Fender", "Stratocastor", "electric", "Alder", "Pine"); inventory.addGuitar("A21457", 0, "Blender", "OakTown Goove", "acoustic", "Oak", "Oak"); inventory.addGuitar("V95693", 1499.95, "Fender", "Stratocastor", "electric", "Alder", "Alder"); inventory.addGuitar("X54321", 0, "Fender Bender", "Stratocastor Light", "electric", "Balsa", "Bass"); inventory.addGuitar("X99876", 0, "Fender Bender", "Stratocastor FeatherWeight", "electric", "Balsa", "Alder"); }
private static void initializeInventory(Inventory inventory) { // Add Guitars to the inventory ... inventory.addGuitar("V12345", 1345.55, new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Adirondack, 6)); inventory.addGuitar("A21457", 900.55, new GuitarSpec(Builder.Collings, "OakTown Goove", Type.acoustic, Wood.Brazilian_Rosewood, Wood.Cedar, 6)); inventory.addGuitar("V95693", 1499.95, new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6)); inventory.addGuitar("X54321", 430.54, new GuitarSpec(Builder.Martin, "Stratocastor Light", Type.electric, Wood.Indian_Rosewood, Wood.Maple, 6)); inventory.addGuitar("X99876", 2000.00, new GuitarSpec(Builder.PRS, "Stratocastor FeatherWeight", Type.electric, Wood.Sitka, Wood.Cocobolo, 6)); inventory.addGuitar("V9512", 1549.95, new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6)); }
private static void InitializeInventory(Inventory inventory) { Dictionary<string, string> properties = new Dictionary<string, string>(); properties["instrumentType"] = InstrumentType.Guitar.ToString(); properties["builder"] = Builder.COLLINGS.ToString(); properties["model"] = "CJ"; properties["type"] = Type.ACOUSTIC.ToString(); properties["numStrings"] = "6"; properties["topWood"] = Wood.INDIAN_ROSEWOOD.ToString(); properties["backWood"] = Wood.SITKA.ToString(); inventory.AddInstrument("11277", 3999.95, new InstrumentSpec(properties)); properties["builder"] = Builder.MARTIN.ToString(); properties["model"] = "D-18"; properties["topWood"] = Wood.MAHOGANY.ToString(); properties["backWood"] = Wood.ALDER.ToString(); inventory.AddInstrument("122784", 5495.95, new InstrumentSpec(properties)); properties["builder"] = Builder.FENDER.ToString(); properties["model"] = "Stratocastor"; properties["type"] = Type.ELECTRIC.ToString(); properties["topWood"] = Wood.ALDER.ToString(); properties["backWood"] = Wood.ALDER.ToString(); inventory.AddInstrument("V95693", 1499.95, new InstrumentSpec(properties)); inventory.AddInstrument("V9512", 1549.95, new InstrumentSpec(properties)); properties["builder"] = Builder.GIBSON.ToString(); properties["model"] = "Les Paul"; properties["topWood"] = Wood.MAPLE.ToString(); properties["backWood"] = Wood.MAPLE.ToString(); inventory.AddInstrument("70108276", 2295.95, new InstrumentSpec(properties)); properties["model"] = "SG '61 Reissue"; properties["topWood"] = Wood.MAHOGANY.ToString(); properties["backWood"] = Wood.MAHOGANY.ToString(); inventory.AddInstrument("82765501", 1890.95, new InstrumentSpec(properties)); properties["instrumentType"] = InstrumentType.Mandolin.ToString(); properties["type"] = Type.ACOUSTIC.ToString(); properties["model"] = "F-5G"; properties["backWood"] = Wood.MAPLE.ToString(); properties["topWood"] = Wood.MAPLE.ToString(); properties.Remove("numStrings"); inventory.AddInstrument("9019920", 5495.99, new InstrumentSpec(properties)); properties["instrumentType"] = InstrumentType.Banjo.ToString(); properties["model"] = "RB-3 Wreath"; properties.Remove("topWood"); properties["numStrings"] = "5"; inventory.AddInstrument("8900231", 2945.95, new InstrumentSpec(properties)); }
private static void InitializeInventory(Inventory inventory) { inventory.AddGuitar("V95693", 1499.95, new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, Wood.ALDER, Wood.ALDER, 12)); inventory.AddGuitar("V95612", 1549.95, new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, Wood.ALDER, Wood.ALDER, 12)); }
static void Main(string[] args) { Inventory inventory = new Inventory(); InitializeInventory(inventory); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("builder", Builder.GIBSON.ToString()); properties.Add("backWood", Wood.MAPLE.ToString()); InstrumentSpec clientSpec = new InstrumentSpec(properties); #region old //GuitarSpec whatEveLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", // Type.ELECTRIC, Wood.ALDER, Wood.ALDER, 12); //MandolinSpec whatEveWants = new MandolinSpec(Builder.FENDER, "Major", Type.ACOUSTIC, Wood.ALDER, Wood.ALDER, Style.A); ////List<Guitar> guitars = inventory.Search(whatEveLikes); //List<Mandolin> mandolins = inventory.Search(whatEveWants); #endregion List<Instrument> matchingInstrument = inventory.Search(clientSpec); #region old //if (mandolins != null) //{ // Console.WriteLine("Mamy w magazynie odpowiedni instrument: "); // foreach (var m in mandolins) // { // MandolinSpec spec = m.Spec; // Console.WriteLine(spec.Builder + " model " + spec.Model + " " // + spec.Type + " :\n " + spec.BackWood + " - tył i boki,\n " + spec.TopWood // + " - góra.\nMożesz ją mieć za " + m.Price + "PLN!\n"); // } //} //else //{ // Console.WriteLine("Przykro mi, nie znalazlem nic dla Ciebie"); //} #endregion if (matchingInstrument.Count > 0) { Console.WriteLine("You might like these instruments:"); foreach (var instrument in matchingInstrument) { InstrumentSpec spec = instrument.Spec; Console.WriteLine("We have a " + spec["instrumentType"] + " with following properties:"); foreach (var propertyName in spec.Properties.Keys) { if (propertyName.Equals("instrumentType")) continue; Console.WriteLine(" " + propertyName + ": " + spec[propertyName]); } Console.WriteLine("You can have this " + spec["instrumentType"] + " for $" + instrument.Price + "\n---"); } } else { Console.WriteLine("Sorry, we have nothing for you"); } }