コード例 #1
0
ファイル: GuitarSpec.cs プロジェクト: 2SANAL/Swabhav-Repo
 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);
 }
コード例 #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!");
            }
        }
コード例 #3
0
ファイル: Inventory.cs プロジェクト: 2SANAL/Swabhav-Repo
        public ArrayList Search(GuitarSpec searchGuitar)
        {
            ArrayList matchingGuitars = new ArrayList();

            foreach (Guitar G in guitars)
            {
                if (G.getSpec().matches(searchGuitar))
                {
                    matchingGuitars.Add(G);
                }
            }
            return(matchingGuitars);
        }
コード例 #4
0
ファイル: Guitar.cs プロジェクト: 2SANAL/Swabhav-Repo
 public Guitar(string _serialNumber, double _price, GuitarSpec _spec)
 {
     this._serialNumber = _serialNumber;
     this._price        = _price;
     this._spec         = _spec;
 }
コード例 #5
0
ファイル: Inventory.cs プロジェクト: 2SANAL/Swabhav-Repo
        public void AddGuitar(string serialno, double price, GuitarSpec spec)
        {
            Guitar guitar = new Guitar(serialno, price, spec);

            guitars.Add(guitar);
        }