Exemplo n.º 1
0
 public bool matches(GuitarSpec spec)
 {
     if (_builder != spec.GetBuilder())
     {
         return(false);
     }
     if ((_model != null) && (!_model.Equals("")) && (!_model.Equals(spec.GetModel())))
     {
         return(false);
     }
     if (_numstring != spec.Getnumstring())
     {
         return(false);
     }
     if (_type != spec.Gettype())
     {
         return(false);
     }
     if (_backwood != spec.GetBackwood())
     {
         return(false);
     }
     if (_topwood != spec.GetTopwood())
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            InitializeInventroy(inventory);
            GuitarSpec whatErinLikes   = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, 12, Wood.ALDER, Wood.ALDER);
            ArrayList  matchingGuitars = inventory.Search(whatErinLikes);

            if (matchingGuitars.Count >= 0)
            {
                Console.WriteLine("Erin,you might like these guitars:");
                foreach (Guitar guitar in matchingGuitars)
                {
                    GuitarSpec spec = guitar.getSpec();
                    Console.WriteLine("We have a " + spec.GetBuilder() + " " + spec.GetModel() + " " + spec.Getnumstring() + " String " +
                                      spec.Gettype() + " guitar:\n    " +
                                      spec.GetBackwood() + " back and sides,\n    " +
                                      spec.GetTopwood() + " top. \n You cac have it for only $" +
                                      guitar.GetPrice() + "!\n  ----");
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin We have nothing for you!");
            }
        }