Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Set up Rick's guitar inventory
            Inventory inventory = new Inventory();
            initializeInventory(inventory);

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

            List<Guitar> guitars = inventory.search(whatErinLikes);

            if (guitars.Count != 0) {
                Console.WriteLine ("Erin, you might like these guitars:");
                foreach (Guitar guitar in guitars) {
                    GuitarSpec guitarSpec = guitar.Spec as GuitarSpec;

                    Console.WriteLine("  We have a " +
                        guitarSpec.Builder + " " + guitarSpec.Model + " " +
                        guitarSpec.Typeg + " guitar:\n     " +
                        guitarSpec.BackWood + " back and sides,\n     " +
                        guitarSpec.TopWood + " top.\n  You can have it for only $" +
                        guitar.Price + "!\n  ----");
                }
            } else {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public List<Guitar> search(GuitarSpec searchSpec)
        {
            List<Guitar> matchingGuitars = new List<Guitar>();

            foreach (Guitar guitar in inventory) {
                if(guitar.Spec.matches(searchSpec)){
                    matchingGuitars.Add(guitar);
                }
            }
            return matchingGuitars;
        }
Exemplo n.º 3
0
        public Guitar(String serialNumber, double price, GuitarSpec spec)
            : base(serialNumber,
			price,spec)
        {
        }