static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            initializeInventory(inventory);

            GuitarSpec    whatErinLikes = new GuitarSpec(Type.ELECTRIC, Builder.FENDER, Wood.ALDER, Wood.ALDER, "Stratocastor", 16);
            List <Guitar> guitars       = inventory.Search(whatErinLikes);

            if (guitars.Count != 0)
            {
                Console.WriteLine("Erin, you might like these guitars : \n");
                foreach (var item in guitars)
                {
                    GuitarSpec guitarSpec = item.Spec;
                    Console.WriteLine(guitarSpec.GetBuilder + " " + guitarSpec.Model + "" +
                                      guitarSpec.GetType + " guitar:\n" +
                                      guitarSpec.BackWood + " back and sides,\n" +
                                      guitarSpec.NumStrings + "num strings are present" +
                                      guitarSpec.TopWood + " top.\nYou can have it for only $" +
                                      item.Price + "!");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
        }
Example #2
0
 public bool Matches(GuitarSpec otherSpec)
 {
     if (builder != otherSpec.builder)
     {
         return(false);
     }
     if ((model != null) && (!model.Equals("")) && (!model.Equals(otherSpec.model)))
     {
         return(false);
     }
     if (type != otherSpec.type)
     {
         return(false);
     }
     if (numStrings != otherSpec.numStrings)
     {
         return(false);
     }
     if (backWood != otherSpec.backWood)
     {
         return(false);
     }
     if (topWood != otherSpec.topWood)
     {
         return(false);
     }
     return(true);
 }
Example #3
0
        public void AddGuitar(String serialNumber, double price, Builder builder, String model, Type type, Wood backWood, Wood topWood, int numStrings)
        {
            GuitarSpec guitarSpec = new GuitarSpec(type, builder, backWood, topWood, model, numStrings);
            Guitar     guitar     = new Guitar(serialNumber, price, guitarSpec);

            guitars.Add(guitar);
        }
Example #4
0
        public List <Guitar> Search(GuitarSpec searchGuitar)
        {
            List <Guitar> matchingGuitar = new List <Guitar>();

            foreach (var guitar in guitars)
            {
                if (guitar.Spec.Matches(searchGuitar))
                {
                    matchingGuitar.Add(guitar);
                }
            }
            return(matchingGuitar);
        }
Example #5
0
 public Guitar(string serialNumber, double price, GuitarSpec spec)
 {
     this.serialNumber = serialNumber;
     this.price        = price;
     this.spec         = spec;
 }