예제 #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);
            }
        }
예제 #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);
 }
예제 #3
0
        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);
        }
예제 #4
0
 public void AddInstrument(string serialnumber, double price, InstrumentSpec spec)
 {
     _inventory.Add(new Instrument(serialnumber, price, spec));
 }
예제 #5
0
 public Instrument(string serialnumber, double price, InstrumentSpec instrumentspec)
 {
     _serialnumber = serialnumber;
     _price        = price;
     _spec         = instrumentspec;
 }