Beispiel #1
0
        static void Main(string[] args)
        {
            Strawberry strawberry = new Strawberry();

            List <IBlendable> blendables = new List <IBlendable>();

            blendables.Add(new Strawberry());
            blendables.Add(new Banana());
            blendables.Add(new CellPhone());
            blendables.Add(new IceCubes());
            for (int i = 0; i < 10; i++)
            {
                blendables.Add(new Mango());
            }


            Banana b = new Banana();

            Console.WriteLine(b.Blend());
            string mess = "";

            foreach (IBlendable blendable in blendables)
            {
                mess += blendable.Blend();
            }

            Console.WriteLine(mess);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var b = new Banana();
            var s = new Strawberry();
            var m = new Mango();
            var c = new IceCubes();
            var p = new CellPhone();

            Console.WriteLine(b.Blend());
            Console.WriteLine(s.Blend());
            Console.WriteLine(m.Blend());


            List <IBlendable> fruits = new List <IBlendable>()
            {
                b, s, m, c, p
            };

            foreach (var fruit in fruits)
            {
                Console.WriteLine(fruit.GetType());
                Console.WriteLine(fruit.Blend());
            }
        }
        static void Main(string[] args)
        {
            var b = new Banana();
            var m = new Mango();
            var s = new Strawberry();
            var c = new IceCubes();

            Console.WriteLine(b.Blend());
            Console.WriteLine(m.Blend());
            Console.WriteLine(s.Blend());

            List <IBlendable> fruits = new List <IBlendable>()
            {
                b, m, s, c
            };

            foreach (var fruit in fruits)
            {
                Console.WriteLine(fruit.Blend());
            }

            foreach (dynamic fruit in fruits)
            {
                Console.WriteLine(fruit.Blend());
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            List <IBlendable> blendables = new List <IBlendable>();

            blendables.Add(new Strawberry());
            blendables.Add(new Banana());
            blendables.Add(new CellPhone());
            blendables.Add(new IceCubes());
            for (int i = 0; i < 10; i++)
            {
                blendables.Add(new Mango());
            }

            Strawberry strawberry = new Strawberry();
            Banana     b          = new Banana();

            Console.WriteLine(b.Blend());
            blendables.Add(b);
            string mess = "";

            ///whatever you are are i wnat you to use what you are
            /// foreach(dynamic i in blendables)
            //{
            //   mess += i.Blend();
            /// }
            ///the right way would be to override the methode
            foreach (IBlendable i in blendables)
            {
                mess += i.Blend();
            }
            Console.WriteLine(mess);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            List <Blendables> items      = new List <Blendables>();
            Strawberry        strawberry = new Strawberry();

            items.Add(strawberry);
            items.Add(new Banana());
            items.Add(new Mango());
            items.Add(new IceCubes());
            items.Add(new CellPhone());

            string result = "";

            foreach (Blendables f in items)
            {
                result = result + f.Blend();
                result = result + ' ';
            }

            Console.WriteLine(result);
            Console.ReadKey();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var b = new Banana();
            var m = new Mango();
            var s = new Strawberry();
            var c = new IceCubes();

            Console.WriteLine(b.Blend());
            Console.WriteLine(m.Blend());
            Console.WriteLine(s.Blend());

            List <IBlendable> fruits = new List <IBlendable> {
                b, m, s, c
            };

            foreach (IBlendable fruit in fruits)
            {
                Console.WriteLine(fruit.Blend());
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            var b = new Banana();
            var m = new Mango();
            var s = new Strawberry();
            var c = new IceCubes();

            Console.WriteLine(b.Blend());
            Console.WriteLine(m.Blend());
            Console.WriteLine(s.Blend());

            List <IBlendable> list = new List <IBlendable>()
            {
                b, m, s, c
            };

            foreach (dynamic blend in list)
            {
                Console.WriteLine(blend.Blend());
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var b = new Banana();
            var m = new Mango();
            var s = new Strawberry();
            var c = new IceCubes();

            Console.Write(b.Blend() + "\n\n");
            Console.Write(m.Blend() + "\n\n");
            Console.Write(s.Blend() + "\n\n");

            List <Iblendable> snax = new List <Iblendable>()
            {
                b, m, s, c
            };

            foreach (Iblendable f in snax)
            {
                Console.Write(f.Blend() + "\n\n");
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var b    = new Banana();
            var m    = new Mango();
            var s    = new Strawberry();
            var ice  = new IceCubes();
            var cell = new CellPhone();

            //Console.WriteLine(b.Blend());
            //Console.WriteLine(m.Blend());
            //Console.WriteLine(s.Blend());

            List <IBlendable> fruits = new List <IBlendable>()
            {
                b, m, s, ice, cell
            };

            foreach (dynamic f in fruits)
            {
                Console.WriteLine(f.Blend());
            }
        }