Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Inventory inventory = new Inventory ();
            initializeInventory(inventory);

            Dictionary<string,object> properties = new Dictionary<string,object>();
            properties.Add("builder", Builder.GIBSON);
            properties.Add("backWood", Wood.MAPLE);
            InstrumentSpec whatBryanLikes = new InstrumentSpec(properties);

            List<Instrument> matchingInstruments = inventory.search(whatBryanLikes);

            if (matchingInstruments.Count != 0) {
                Console.WriteLine ("Bryan, you might like these instruments:");
                foreach (Instrument instrument in matchingInstruments) {
                    InstrumentSpec instrumentSpec = instrument.Spec;
                    Console.WriteLine("  We have a " + instrumentSpec.getProperty("instrumentType") + " with the following properties:");
                    foreach (KeyValuePair<string,object> kvproperty in instrumentSpec.getProperties()) {
                        if (kvproperty.Key == "instrumentType")
                            continue;
                        Console.WriteLine("    " + kvproperty.Key + ": " + kvproperty.Value);
                    }
                            Console.WriteLine("  You can have this " +
                                instrumentSpec.getProperty("instrumentType") + " for $" +
                                instrument.Price + "\n---");
                }
            } else {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
            Console.ReadKey();
        }
        public static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            initializeInventory(inventory);

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("builder", Builder.GIBSON);
            properties.Add("backWood", Wood.MAPLE);
            InstrumentSpec whatBryanLikes = new InstrumentSpec(properties);

            List <Instrument> matchingInstruments = inventory.search(whatBryanLikes);

            if (matchingInstruments.Count != 0)
            {
                Console.WriteLine("Bryan, you might like these instruments:");
                foreach (Instrument instrument in matchingInstruments)
                {
                    InstrumentSpec instrumentSpec = instrument.Spec;
                    Console.WriteLine("  We have a " + instrumentSpec.getProperty("instrumentType") + " with the following properties:");
                    foreach (KeyValuePair <string, object> kvproperty in instrumentSpec.getProperties())
                    {
                        if (kvproperty.Key == "instrumentType")
                        {
                            continue;
                        }
                        Console.WriteLine("    " + kvproperty.Key + ": " + kvproperty.Value);
                    }
                    Console.WriteLine("  You can have this " +
                                      instrumentSpec.getProperty("instrumentType") + " for $" +
                                      instrument.Price + "\n---");
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
            Console.ReadKey();
        }