Example #1
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            InitaliztionInventory(inventory);

            Instrument instrument = inventory.GetInstrument("11277");

            DisplayInstrumentInformation(instrument);

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

            properties.Add("Model", "CJ");
            properties.Add("Builder", Builder.COLLINGS);

            InstrumentSpec searchspec = new InstrumentSpec(properties);

            Console.WriteLine();
            Console.WriteLine("Search result:");
            Console.WriteLine();

            List <Instrument> result = inventory.Search(searchspec);

            foreach (Instrument instrument1 in result)
            {
                DisplayInstrumentInformation(instrument1);
            }
        }
Example #2
0
 public bool Matches(InstrumentSpec spec)
 {
     foreach (KeyValuePair <string, object> property in spec.Properties)
     {
         if (!property.Value.Equals(this.GetProperty(property.Key)))
         {
             return(false);
         }
     }
     return(true);
 }
        public List <Instrument> Search(InstrumentSpec spec)
        {
            List <Instrument> matchinginstruments = new List <Instrument>();

            foreach (Instrument instrument in _inventory)
            {
                if (instrument.InstrumentSpecifiction.Matches(spec))
                {
                    matchinginstruments.Add(instrument);
                }
            }
            return(matchinginstruments);
        }
 public void AddInstrument(string serialnumber, double price, InstrumentSpec spec)
 {
     _inventory.Add(new Instrument(serialnumber, price, spec));
 }
 public Instrument(string serialnumber, double price, InstrumentSpec instrumentspec)
 {
     _serialnumber = serialnumber;
     _price        = price;
     _spec         = instrumentspec;
 }