Exemple #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);
 }
Exemple #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!");
            }
        }
Exemple #3
0
        public ArrayList Search(GuitarSpec searchGuitar)
        {
            ArrayList matchingGuitars = new ArrayList();

            foreach (Guitar G in guitars)
            {
                if (G.getSpec().matches(searchGuitar))
                {
                    matchingGuitars.Add(G);
                }
            }
            return(matchingGuitars);
        }
Exemple #4
0
 public Guitar(string _serialNumber, double _price, GuitarSpec _spec)
 {
     this._serialNumber = _serialNumber;
     this._price        = _price;
     this._spec         = _spec;
 }
Exemple #5
0
        public void AddGuitar(string serialno, double price, GuitarSpec spec)
        {
            Guitar guitar = new Guitar(serialno, price, spec);

            guitars.Add(guitar);
        }