Esempio n. 1
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            InitializeInventory(inventory);
            Guitar        guitarsILike = new Guitar("", 0, EnumDefinition.Builder.FENDER, "Stratocastor", EnumDefinition.Type.ELECTRIC, EnumDefinition.Wood.ALDER, EnumDefinition.Wood.ALDER);
            List <Guitar> guitars      = inventory.Search(guitarsILike);

            if (guitars.Count > 0)
            {
                foreach (var item in guitars)
                {
                    Console.WriteLine("Builder : " + item.getBuilder() + "\n" + "Model : " + "Model : " + item.getModel() + "\n" + "Type:" + item.getType() + "\n" + "BackWood : " + item.getBackWood() + "\n" + "TopWood : " + item.getTopWood() + "\n" + "Price : " + item.getPrice());
                }
            }
            else
            {
                Console.WriteLine("We have Nothing For You");
            }
            // add params
            //inventory.addGuitar();
            //inventory.getGuitar();
            // Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
        public List <Guitar> Search(Guitar searchGuitar)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            foreach (var guitar in guitars)
            {
                if (searchGuitar.getBuilder() != guitar.getBuilder())
                {
                    continue;
                }

                string model = searchGuitar.getModel();
                if ((model != null) && (!model.Equals("")) && (!model.Equals(guitar.getModel())))
                {
                    continue;
                }

                if (searchGuitar.getType() != guitar.getType())
                {
                    continue;
                }

                if (searchGuitar.getBackWood() != guitar.getBackWood())
                {
                    continue;
                }

                if (searchGuitar.getTopWood() != guitar.getTopWood())
                {
                    continue;
                }

                matchingGuitars.Add(guitar);
                //return guitar;
            }
            return(matchingGuitars);
        }
        public void addGuitar(string serialNumber, double price, EnumDefinition.Builder builder, string model, EnumDefinition.Type type, EnumDefinition.Wood backWood, EnumDefinition.Wood topWood)
        {
            Guitar guitar = new Guitar(serialNumber, price, builder, model, type, backWood, topWood);

            guitars.Add(guitar);
        }