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

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

            if (guitars != null)
            {
                Console.WriteLine("Mamy w magazynie odpowiednią gitarę: ");
                foreach (var g in guitars)
                {
                    GuitarSpec spec = g.Spec;
                    Console.WriteLine(spec.Builder + " model " + spec.Model + " "
                        + spec.Type + " :\n " + spec.BackWood + " - tył i boki,\n " + spec.TopWood
                        + " - góra.\nMożesz ją mieć za " + g.Price + "PLN!\n");
                }

            }
            else
            {
                Console.WriteLine("Przykro mi, nie znalazlem nic dla Ciebie");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            initializeInvetory(inventory);

            GuitarSpec    whatErinLikes   = new GuitarSpec(Builder.FENDER, "Stratocastor", Type.ELECTRIC, Wood.MAPLE, Wood.CEDAR);
            List <Guitar> matchingGuitars = inventory.search(whatErinLikes);

            if (matchingGuitars != null)
            {
                Console.WriteLine("Erin, you might like these guitars :");

                foreach (Guitar guitar in matchingGuitars)  // we can use foreach instead of IEnumerator to loop thorugh the collection
                {
                    GuitarSpec spec = guitar.getSpec();
                    Console.WriteLine(" We have a " +
                                      spec.getBuilder() + " " + spec.getModel() + " " +
                                      spec.getType() + " guitar : \n    " +
                                      spec.getBackWood() + " back and sides, \n    " +
                                      spec.getTopWood() + " top. \nYou can have it only for $" +
                                      guitar.getPrice() + " ! ");
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
        }
        public static void testErin()
        {
            // Set up Rick's guitar inventory
            Inventory inventory = new Inventory();
            initializeInventory(inventory);

            GuitarSpec whatErinLikes = new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6);
            List<Guitar> guitars = inventory.search(whatErinLikes);
            if (guitars.Count > 0)
            {
                string msgSuccess = "Erin, you might like these guitars: ";
                foreach (Guitar guitar in guitars)
                {
                    GuitarSpec spec = guitar.spec;
                    msgSuccess +=   "\nWe have a " +
                        Enumerations.GetEnumDescription(spec.builder) + " " + spec.model + " " +
                        Enumerations.GetEnumDescription(spec.type) + " guitar:\n    " +
                        Enumerations.GetEnumDescription(spec.backWood) + " back and sides,\n    " +
                        Enumerations.GetEnumDescription(spec.topWood) + " top.\nYou can have it for only $" +
                        guitar.price + "!\n  ----";
                }
                Console.WriteLine(msgSuccess);
                Console.ReadKey();
            }
            else
            {
                string msgFail = "Sorry, Erin, we have nothing for you.";
                Console.WriteLine(msgFail);
                Console.ReadKey();
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            InitializeInventory(inventory);

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

            if (guitars != null)
            {
                Console.WriteLine("Mamy w magazynie odpowiednią gitarę: ");
                foreach (var g in guitars)
                {
                    GuitarSpec spec = g.Spec;
                    Console.WriteLine(spec.Builder + " model " + spec.Model + " "
                                      + spec.Type + " :\n " + spec.BackWood + " - tył i boki,\n " + spec.TopWood
                                      + " - góra.\nMożesz ją mieć za " + g.Price + "PLN!\n");
                }
            }
            else
            {
                Console.WriteLine("Przykro mi, nie znalazlem nic dla Ciebie");
            }
        }
Exemplo n.º 5
0
 public void addGuitar(string serialNumber,
                         double price,
                         GuitarSpec spec)
 {
     Guitar guitar = new Guitar(serialNumber, price, spec);
     _guitars.Add(guitar);
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var inventory = new Inventory();

            InitializeInventory(inventory);

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

            List <Guitar> mathcingGuitars = inventory.Search(whatErinLikes);

            if (!mathcingGuitars.Equals(null))
            {
                Console.WriteLine("Erin,You might like this guitars..");

                foreach (var guitar in mathcingGuitars)
                {
                    GuitarSpec spec = guitar.Spec;
                    Console.WriteLine("  We have a " +
                                      spec.Builder + " " + spec.Model + " " +
                                      spec.Type + " guitar:\n     " +
                                      spec.BackWood + " back and sides,\n     " +
                                      spec.TopWood + " top.\n  You can have it for only $" +
                                      guitar.Price + "!\n  ----");
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin,we have nothing for you....");
            }
        }
Exemplo n.º 7
0
        public bool Matches(GuitarSpec otherSpec)
        {
            if (builder != otherSpec.builder)
            {
                return(false);
            }
            if ((model != null) && (!model.Equals("")) &&
                (!model.ToLower().Equals(otherSpec.model.ToLower())))
            {
                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);
        }
Exemplo n.º 8
0
        public bool matches(GuitarSpec spec)
        {
            // Ignore serial # since that's unique
            // Ignore price since that's unique

            // Check if matches fail
            if (builder != spec.builder)
            {
                return(false);
            }
            if (!stringsMatch(model, spec.model))
            {
                return(false);
            }
            if (type != spec.type)
            {
                return(false);
            }
            if (backWood != spec.backWood)
            {
                return(false);
            }
            if (topWood != spec.topWood)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        public static void testErin()
        {
            // Set up Rick's guitar inventory
            Inventory inventory = new Inventory();

            initializeInventory(inventory);

            GuitarSpec    whatErinLikes = new GuitarSpec(Builder.Fender, "Stratocastor", Type.electric, Wood.Alder, Wood.Alder, 6);
            List <Guitar> guitars       = inventory.search(whatErinLikes);

            if (guitars.Count > 0)
            {
                string msgSuccess = "Erin, you might like these guitars: ";
                foreach (Guitar guitar in guitars)
                {
                    GuitarSpec spec = guitar.spec;
                    msgSuccess += "\nWe have a " +
                                  Enumerations.GetEnumDescription(spec.builder) + " " + spec.model + " " +
                                  Enumerations.GetEnumDescription(spec.type) + " guitar:\n    " +
                                  Enumerations.GetEnumDescription(spec.backWood) + " back and sides,\n    " +
                                  Enumerations.GetEnumDescription(spec.topWood) + " top.\nYou can have it for only $" +
                                  guitar.price + "!\n  ----";
                }
                Console.WriteLine(msgSuccess);
                Console.ReadKey();
            }
            else
            {
                string msgFail = "Sorry, Erin, we have nothing for you.";
                Console.WriteLine(msgFail);
                Console.ReadKey();
            }
        }
Exemplo n.º 10
0
        public void addGuitar(string serialNumber,
                              double price,
                              GuitarSpec spec)
        {
            Guitar guitar = new Guitar(serialNumber, price, spec);

            _guitars.Add(guitar);
        }
Exemplo n.º 11
0
 public Guitar(string serialNumber,
                 double price,
                 GuitarSpec spec)
 {
     this.serialNumber = serialNumber;
     this.price = price;
     this.spec = spec;
 }
Exemplo n.º 12
0
 public Guitar(string serialNumber,
               double price,
               GuitarSpec spec)
 {
     this.serialNumber = serialNumber;
     this.price        = price;
     this.spec         = spec;
 }
Exemplo n.º 13
0
 public Guitar(string serialNumber,
               double price,
               Builder builder,
               string model,
               Type type,
               Wood backWood,
               Wood topWood)
 {
     this.serialNumber = serialNumber;
     this.price        = price;
     this.spec         = new GuitarSpec(builder, model, type, backWood, topWood);
 }
Exemplo n.º 14
0
        public List<Guitar> Search(GuitarSpec searchSpec)
        {
            List<Guitar> matchingGuitars = new List<Guitar>();

            foreach (var guitar in guitars)
            {
                GuitarSpec guitarSpec = guitar.Spec;
                if (guitar.Spec.Matches(searchSpec))
                    matchingGuitars.Add(guitar);
            }
            return matchingGuitars;
        }
Exemplo n.º 15
0
 public Guitar(string serialNumber,
                 double price,
                 Builder builder,
                 string model,
                 Type type,
                 Wood backWood,
                 Wood topWood)
 {
     this.serialNumber = serialNumber;
     this.price = price;
     this.spec = new GuitarSpec(builder, model, type, backWood, topWood);
 }
Exemplo n.º 16
0
        public List <Guitar> Search(GuitarSpec searchSepc)
        {
            List <Guitar> matchingGuitar = new List <Guitar>();

            foreach (var guitar in guitars)
            {
                if (guitar.Spec.Matches(searchSepc))
                {
                    matchingGuitar.Add(guitar);
                }
            }
            return(matchingGuitar);
        }
Exemplo n.º 17
0
 public bool Matches(GuitarSpec otherSpec)
 {
     if (builder != otherSpec.Builder)
         return false;
     if ((model != null) && (model != "") && (model.ToLower() != otherSpec.Model.ToLower()))
         return false;
     if (type != otherSpec.Type)
         return false;
     if (backwood != otherSpec.BackWood)
         return false;
     if (topwood != otherSpec.TopWood)
         return false;
     return true;
 }
Exemplo n.º 18
0
        public bool matches(GuitarSpec spec)
        {
            // Ignore serial # since that's unique
            // Ignore price since that's unique

            // Check if matches fail
            if (builder != spec.builder) { return false; }
            if (!stringsMatch(model, spec.model)) { return false; }
            if (type != spec.type) { return false; }
            if (backWood != spec.backWood) { return false; }
            if (topWood != spec.topWood) { return false; }

            return true;
        }
Exemplo n.º 19
0
        public List<Guitar> search(GuitarSpec searchSpec)
        {
            List<Guitar> matchingGuitars = new List<Guitar>();
            for (int i = 0; i < _guitars.Count; i++)
            {
                Guitar guitar = _guitars[i];
                GuitarSpec guitarSpec = guitar.spec;

                if (guitarSpec.matches(searchSpec))
                {
                    matchingGuitars.Add(guitar);
                }
                
            }
            return matchingGuitars;
        }
Exemplo n.º 20
0
        public List <Guitar> search(GuitarSpec searchSpec)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            for (int i = 0; i < _guitars.Count; i++)
            {
                Guitar     guitar     = _guitars[i];
                GuitarSpec guitarSpec = guitar.spec;

                if (guitarSpec.matches(searchSpec))
                {
                    matchingGuitars.Add(guitar);
                }
            }
            return(matchingGuitars);
        }
Exemplo n.º 21
0
        public List<Guitar> search(GuitarSpec searchSpec)
        {
            List<Guitar> matchingGuitars = new List<Guitar>();
            for (int i = 0; i < _guitars.Count; i++)
            {
                Guitar guitar = _guitars[i];
                GuitarSpec guitarSpec = guitar.spec;
                // Ignore serial # since that's unique
                // Ignore price since that's unique

                // Check if matches fail
                if (searchSpec.builder != guitarSpec.builder) { continue; }
                if (!stringsMatch(searchSpec.model, guitarSpec.model)) { continue; }
                if (searchSpec.type != guitarSpec.type) { continue; }
                if (searchSpec.backWood != guitarSpec.backWood) { continue; }
                if (searchSpec.topWood != guitarSpec.topWood) { continue; }

                matchingGuitars.Add(guitar);
            }
            return matchingGuitars;
        }
Exemplo n.º 22
0
        public List <Guitar> search(GuitarSpec searchSpec)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            for (IEnumerator i = guitars.GetEnumerator(); i.MoveNext();)
            {
                Guitar     guitar     = (Guitar)i.Current;
                GuitarSpec guitarSpec = guitar.getSpec();
                // Ignore serial number since that's uniquer
                // Ignore price since that's unique
                string builder = searchSpec.getBuilder();
                if (searchSpec.getBuilder() != searchSpec.getBuilder())
                {
                    continue;
                }
                String model = searchSpec.getModel().ToLower();
                if ((model != null) && (!model.Equals("")) && (!model.Equals(guitarSpec.getModel().ToLower())))
                {
                    continue;
                }
                if (searchSpec.getType() != guitarSpec.getType())
                {
                    continue;
                }
                if (searchSpec.getBackWood() != guitarSpec.getBackWood())
                {
                    continue;
                }
                if (searchSpec.getTopWood() != guitarSpec.getTopWood())
                {
                    continue;
                }

                matchingGuitars.Add(guitar);
            }
            return(matchingGuitars);
        }
Exemplo n.º 23
0
        public List <Guitar> search(GuitarSpec searchSpec)
        {
            List <Guitar> matchingGuitars = new List <Guitar>();

            for (int i = 0; i < _guitars.Count; i++)
            {
                Guitar     guitar     = _guitars[i];
                GuitarSpec guitarSpec = guitar.spec;
                // Ignore serial # since that's unique
                // Ignore price since that's unique

                // Check if matches fail
                if (searchSpec.builder != guitarSpec.builder)
                {
                    continue;
                }
                if (!stringsMatch(searchSpec.model, guitarSpec.model))
                {
                    continue;
                }
                if (searchSpec.type != guitarSpec.type)
                {
                    continue;
                }
                if (searchSpec.backWood != guitarSpec.backWood)
                {
                    continue;
                }
                if (searchSpec.topWood != guitarSpec.topWood)
                {
                    continue;
                }

                matchingGuitars.Add(guitar);
            }
            return(matchingGuitars);
        }
Exemplo n.º 24
0
 public bool Matches(GuitarSpec otherSpec)
 {
     if (builder != otherSpec.Builder)
     {
         return(false);
     }
     if ((model != null) && (model != "") && (model.ToLower() != otherSpec.Model.ToLower()))
     {
         return(false);
     }
     if (type != otherSpec.Type)
     {
         return(false);
     }
     if (backwood != otherSpec.BackWood)
     {
         return(false);
     }
     if (topwood != otherSpec.TopWood)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 25
0
 public void AddGuitar(string serialNumber, double price, GuitarSpec spec)
 {
     var guitar = new Guitar(serialNumber, price, spec);
     guitars.AddLast(guitar);
 }
Exemplo n.º 26
0
        public void AddGuitar(string serialNumber, double price, GuitarSpec spec)
        {
            var guitar = new Guitar(serialNumber, price, spec);

            guitars.AddLast(guitar);
        }
Exemplo n.º 27
0
 public Guitar(string serialNumber, double price, GuitarSpec spec)
     : base(serialNumber, price, spec)
 {
     this.spec = spec;
 }
Exemplo n.º 28
0
 public Guitar(string serialNumber, double price, GuitarSpec spec) : base(serialNumber, price, spec)
 {
     this.spec = spec;
 }