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);
 }
Example #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();
                    ConvertToString c    = new ConvertToString();
                    Console.WriteLine("\nWe have a " + c.BuilderToString(spec.GetBuilder()) + " " + spec.GetModel() + " " + spec.Getnumstring() + " String " +
                                      c.TypeToString(spec.Gettype()) + " guitar:\n    " +
                                      c.WoodToString(spec.GetBackwood()) + " back and sides,\n    " +
                                      c.WoodToString(spec.GetTopwood()) + " top. \n You cac have it for only $" +
                                      guitar.GetPrice() + "!\n  ----");
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin We have nothing for you!");
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            ConvertToString convert   = new ConvertToString();
            Inventory       inventory = new Inventory();

            InitializeInventory(inventory);
            GuitarSpec WhatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocastor",
                                                      Type.ELECTRIC, 6, Wood.ALDER, Wood.ALDER);
            List <Instrument> MatchingGuitars = inventory.Search(WhatErinLikes);

            if (MatchingGuitars.Count >= 0)
            {
                Console.WriteLine("Erin, you might like these guitars :");

                foreach (Guitar guit in MatchingGuitars)
                {
                    GuitarSpec spec = (GuitarSpec)guit.Spec;
                    Console.WriteLine("We have a " + convert.BuilderToString(spec.Builder) +
                                      " " + spec.Model + " " + convert.TypeToString(spec.Type) + " " +
                                      convert.WoodToString(spec.Backwood) + " Back and Sides " +
                                      convert.WoodToString(spec.Topwood));

                    Console.WriteLine("You can have it for just $" + guit.Price);
                }
            }
            else
            {
                Console.WriteLine("Sorry, we nothing for you....");
            }
            MandolinSpec WhatAkashLikes = new MandolinSpec(Builder.COLLINGS, "Stratocastor",
                                                           Type.ACOUSTIC, Style.A, Wood.ADIRONDACK, Wood.ADIRONDACK);
            List <Instrument> MatchingMandolins = inventory.Search(WhatAkashLikes);

            if (MatchingMandolins.Count >= 0)
            {
                Console.WriteLine("Erin, you might like these mandolin :");


                foreach (Mandolin mandolin in MatchingMandolins)
                {
                    MandolinSpec spec = (MandolinSpec)mandolin.Spec;
                    Console.WriteLine("We have a " + convert.BuilderToString(spec.Builder)
                                      + " " + spec.Model + " " + convert.TypeToString(spec.Type) + " " +
                                      convert.WoodToString(spec.Backwood) + " Back and Sides " +
                                      convert.WoodToString(spec.Topwood));

                    Console.WriteLine("You can have it for just $" + mandolin.Price);
                }
            }
            else
            {
                Console.WriteLine("Sorry, we nothing for you....");
            }
        }
        public ArrayList Search(GuitarSpec searchGuitar)
        {
            ArrayList matchingGuitars = new ArrayList();

            foreach (Guitar G in guitars)
            {
                if (G.GetSpec().matches(searchGuitar))
                {
                    matchingGuitars.Add(G);
                }
            }
            return(matchingGuitars);
        }
Example #5
0
        public List <Instrument> Search(GuitarSpec searchspec)
        {
            List <Instrument> MatchingGuitar = new List <Instrument>();

            for (int i = 0; i < instruments.Count; i++)
            {
                if (instruments[i] is Guitar)
                {
                    if (instruments[i].Spec.Matches(searchspec))
                    {
                        MatchingGuitar.Add(instruments[i]);
                    }
                }
            }
            return(MatchingGuitar);
        }
Example #6
0
        public override bool Matches(InstrumentSpec otherspec)
        {
            if (!(base.Matches(otherspec)))
            {
                return(false);
            }
            if (!(otherspec.GetType() == typeof(GuitarSpec)))
            {
                return(false);
            }

            GuitarSpec spec = (GuitarSpec)otherspec;

            if (_numStrings != spec._numStrings)
            {
                return(false);
            }
            return(true);
        }
Example #7
0
 public Guitar(string serialno, double price, GuitarSpec spec)
 {
     _serialNo = serialno;
     _price    = price;
     _spec     = spec;
 }
Example #8
0
        // private GuitarSpec _spec;

        public Guitar(string serialNumber, double price, GuitarSpec guitarspec) : base(serialNumber, price, guitarspec)
        {
        }
        public void AddGuitar(string serialno, double price, GuitarSpec spec)
        {
            Guitar guitar = new Guitar(serialno, price, spec);

            guitars.Add(guitar);
        }