Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SandwichMenu sandwichMenu = new SandwichMenu();

            // Initialize with default sandwiches
            sandwichMenu["BLT"]
                = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
            sandwichMenu["PB&J"]
                = new Sandwich("White", "", "", "Peanut Butter, Jelly");
            sandwichMenu["Turkey"]
                = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion, Tomato");

            // Deli manager adds custom sandwiches
            sandwichMenu["LoadedBLT"]
                = new Sandwich("Wheat", "Turkey, Bacon", "American", "Lettuce, Tomato, Onion, Olives");
            sandwichMenu["ThreeMeatCombo"]
                = new Sandwich("Rye", "Turkey, Ham, Salami", "Provolone", "Lettuce, Onion");
            sandwichMenu["Vegetarian"]
                = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Spinach");

            // Now we can clone these sandwiches
            Sandwich sandwich1 = sandwichMenu["BLT"].Clone() as Sandwich;
            Sandwich sandwich2
                = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
            Sandwich sandwich3
                = sandwichMenu["Vegetarian"].Clone() as Sandwich;

            // Wait for user
            Console.ReadKey();
        }
        public static void Main(string[] args)
        {
            var menu = new SandwichMenu();

            menu["BLT"] = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");

            menu["LoadedBLT"] = new Sandwich("", "", "", "");

            var bltSandwich = menu["BLT"].Clone() as Sandwich;
        }
Exemplo n.º 3
0
        public static void Main()
        {
            SandwichMenu menu = new SandwichMenu();

            //Initialize with default sandwiches
            menu["BLT"]    = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
            menu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion, Tomato");

            //Now we can clone these sandwiches
            Sandwich sandwich1 = menu["BLT"].Clone() as Sandwich;
            Sandwich sandwich2 = menu["Turkey"].Clone() as Sandwich;
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            SandwichMenu sandwichMenu = new SandwichMenu();

            sandwichMenu["A"] = new Sandwich("A", "A", "A", "A");
            sandwichMenu["B"] = new Sandwich("B", "B", "B", "B");
            sandwichMenu["C"] = new Sandwich("C", "C", "C", "C");
            sandwichMenu["D"] = new Sandwich("D", "D", "D", "D");

            Sandwich copyA = sandwichMenu["A"].Clone() as Sandwich;
            Sandwich copyB = sandwichMenu["B"].Clone() as Sandwich;
            Sandwich copyC = sandwichMenu["C"].Clone() as Sandwich;
        }
Exemplo n.º 5
0
        public static void Main()
        {
            SandwichMenu sandwichMenu = new SandwichMenu();

            sandwichMenu["BLT"]    = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
            sandwichMenu["PB&J"]   = new Sandwich("White", "", "", "Peanut Butter, Jelly");
            sandwichMenu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion, Tomato");

            sandwichMenu["LoadedBLT"]      = new Sandwich("Wheat", "Ham, Bacon", "American", "Lettuce, Tomato, Onion, Olives");
            sandwichMenu["ThreeMeatCombo"] = new Sandwich("Rye", "Turkey, Ham, Bacon", "Swiss", "Lettuce, Tomato, Onion");
            sandwichMenu["Vegetarian"]     = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Cucumber");

            Sandwich sandwich1 = sandwichMenu["LoadedBLT"].Clone() as Sandwich;
            Sandwich sandwich2 = sandwichMenu["PB&J"].Clone() as Sandwich;
            Sandwich sandwich3 = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            SandwichMenu sandwichMenu = new SandwichMenu();

            sandwichMenu["BLT"]    = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
            sandwichMenu["PBJ"]    = new Sandwich("White", "", "", "Peanut Butter, Jelly");
            sandwichMenu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion,Tomato");

            sandwichMenu["LoadedBLT"]      = new Sandwich("Wheat", "Turkey, Bacon", "American", "Lettuce, Tomato, Onion, Olives");
            sandwichMenu["ThreeMeatCombo"] = new Sandwich("Rye", "Turkey, Ham, Salami", "Provolone", "Lettuce, Onion");
            sandwichMenu["Vegetarian"]     = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Spinach");

            Sandwich sandwich1 = sandwichMenu["BLT"].Clone() as Sandwich;
            Sandwich sandwich2 = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
            Sandwich sandwich3 = sandwichMenu["Vegetarian"].Clone() as Sandwich;
        }
Exemplo n.º 7
0
        static void Sandwhiches()
        {
            var      sandwichMenu = new SandwichMenu();
            Sandwich sandwich1    = sandwichMenu["BLT"].Clone() as Sandwich;
            Sandwich sandwich2    = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
            Sandwich sandwich3    = sandwichMenu["Vegetarian"].Clone() as Sandwich;

            try
            {
                var noSandwich = sandwichMenu["TEST"].Clone() as Sandwich;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            var sandwichMenu = new SandwichMenu();

            sandwichMenu["BLT"] = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");

            sandwichMenu["PB&J"] = new Sandwich("White", "", "", "Peanut Butter, Jelly");

            sandwichMenu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "lettuce, Onion, Tomato");

            sandwichMenu["LoadedBLT"] = new Sandwich("Wheat", "Turkey, Bacon", "American", "Lettuce, Tomato, Onion, Olives");

            sandwichMenu["ThreeMeatCombo"] = new Sandwich("Rye", "Turkey, Ham, Salami", "Provolone", "Lettuce, Onion");

            sandwichMenu["Vegetarian"] = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Spinach");

            var bltSandwich = sandwichMenu["BLT"].Clone() as Sandwich;

            Console.WriteLine();

            var threeMeatComboSandwich = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
        }