Exemplo n.º 1
0
 public bool matches(GuitarSpec otherSpec)
 {
     if (builder != otherSpec.builder)
     {
         return(false);
     }
     else if ((model != null) && (!model.Equals("")) && (!model.ToLower().Equals(otherSpec.model.ToLower())))
     {
         return(false);
     }
     else if (type != otherSpec.type)
     {
         return(false);
     }
     else if (numStrings != otherSpec.numStrings)
     {
         return(false);
     }
     else if (backWood != otherSpec.backWood)
     {
         return(false);
     }
     else if (topWood != otherSpec.topWood)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            FindGuitarTester mainCls   = new FindGuitarTester();
            Inventory        inventory = new Inventory();

            mainCls.initalizeInventory(inventory);

            GuitarSpec whatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, 6, Wood.ALDER, Wood.ALDER);

            List <object> machingGuitars = inventory.search(whatErinLikes);

            if (!machingGuitars.Equals(null))
            {
                Console.WriteLine("Erin, you might like these guitars:");
                int index = 0;
                foreach (var i in machingGuitars)
                {
                    Guitar     guitar = (Guitar)machingGuitars[index];
                    GuitarSpec spec   = guitar.GetSpec();
                    Console.WriteLine("We have a " + spec.getBuilder().ToString().ToLower() + " " + spec.getModel() + " " + spec.getType().ToString().ToLower() + " guitar:\n" + spec.getBackWood().ToString().ToLower() + " back and sides,\n" + spec.getTopWood().ToString().ToLower() + " top.\n You can have it for only $" + guitar.getPrice() + "!\n");
                    index++;
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
        }
Exemplo n.º 3
0
        public List <object> search(GuitarSpec searchSpec)
        {
            List <object> matchingGuitars = new List <object>();
            int           index           = 0;

            foreach (var i in guitars)
            {
                Guitar guitar = (Guitar)guitars[index];
                if (guitar.GetSpec().matches(searchSpec))
                {
                    matchingGuitars.Add(guitar);
                }
                index++;
            }
            return(matchingGuitars);
        }
Exemplo n.º 4
0
        public void addGuitar(String serialNumber, double price, GuitarSpec spec)
        {
            Guitar guitar = new Guitar(serialNumber, price, spec);

            guitars.Add(guitar);
        }
Exemplo n.º 5
0
 public Guitar(String serialNumber, double price, GuitarSpec spec)
 {
     this.serialNumber = serialNumber;
     this.price        = price;
     this.spec         = spec;
 }