コード例 #1
0
ファイル: Inventory.cs プロジェクト: juanferfranco/PDOO
        public Guitar search(Guitar searchGuitar)
        {
            foreach (Guitar guitar in guitars) {
                // Ignore serial number since that's unique
                // Ignore price since that's unique

                string builder = searchGuitar.Builder;
                if ((builder != null) && (!builder.Equals("")) &&
                    (!builder.Equals(guitar.Builder)))
                    continue;

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

                string type = searchGuitar.Typeg;
                if ((type != null) && (!searchGuitar.Equals("")) &&
                    (!type.Equals(guitar.Typeg)))
                    continue;

                string backWood = searchGuitar.BackWood;
                if ((backWood != null) && (!backWood.Equals("")) &&
                    (!backWood.Equals(guitar.BackWood)))
                    continue;

                string topWood = searchGuitar.TopWood;
                if ((topWood != null) && (!topWood.Equals("")) &&
                    (!topWood.Equals(guitar.TopWood)))
                    continue;

                return guitar;
            }
            return null;
        }
コード例 #2
0
ファイル: Inventory.cs プロジェクト: juanferfranco/PDOO
        public void addGuitar(string serialNumber, double price,
			string builder, string model,
			string type, string backWood, string topWood)
        {
            Guitar guitar = new Guitar(serialNumber, price, builder,
                model, type, backWood, topWood);

            guitars.Add(guitar);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: juanferfranco/PDOO
        public static void Main(string[] args)
        {
            // Set up Rick's guitar inventory
            Inventory inventory = new Inventory();
            initializeInventory(inventory);

            Guitar whatErinLikes = new Guitar("", 0, "fender", "Stratocastor",
                "electric", "Alder", "Alder");
            Guitar guitar = inventory.search(whatErinLikes);
            if (guitar != null) {
                Console.WriteLine("Erin, you might like this " +
                    guitar.Builder + " " + guitar.Model +  " " +
                    guitar.Typeg + " guitar:\n   " +
                    guitar.BackWood + " back and sides,\n   " +
                    guitar.TopWood + " top.\nYou can have it for only $" +
                    guitar.Price + "!");
            } else {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
            Console.ReadKey();
        }