Beispiel #1
0
        public void CallingInterfaceMethods()
        {
            // New up an instance of an IFruit
            IFruit fruit = new Banana();  //we are calling Banana BUT will only have the properties of IFruit, can't just call on interfaces like other classes. In this example it will take on the name of the banana put ONLY have access to the IFruit properties in Banana.

            string output = fruit.Peel();

            Console.WriteLine(output);
            Console.WriteLine("The banana is peeled: " + fruit.Peeled);
        }
Beispiel #2
0
        public void CallingInterfaceMethods()
        {
            // New up an instance of an Ifruit
            IFruit banana = new Banana();

            string output = banana.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {banana.Name} is peeled: " + banana.Peeled);
        }
Beispiel #3
0
        public void CallingInterfaceMethods()
        {
            IFruit banana  = new Banana();
            Banana banana1 = new Banana();
            // Can't create an interface object
            // IFruit banana = new IFruit();

            // var is like a wildcard argument
            var output = banana.Peel();

            Console.WriteLine(output);

            Console.WriteLine("The banana is peeled: " + banana.IsPeeled);
            Assert.IsTrue(banana.IsPeeled);
        }
Beispiel #4
0
        public void TestMethod1()
        {
            Orange orange         = new Orange(true);
            Orange unpeeledOrange = new Orange(false);

            Console.WriteLine(orange.IsPeeled);
            Console.WriteLine(unpeeledOrange.IsPeeled);

            Console.WriteLine(orange.Peel());
            Console.WriteLine(unpeeledOrange.Peel());

            Banana banana = new Banana();

            List <IFruit> fruitBasket = new List <IFruit>();

            fruitBasket.Add(banana);
            fruitBasket.Add(orange);
        }
Beispiel #5
0
        public void FruitTest()
        {
            Orange foo            = new Orange(true);
            Orange unpeeledOrange = new Orange(false);

            Console.WriteLine(foo.IsPeeled);
            Console.WriteLine(unpeeledOrange.IsPeeled);

            Console.WriteLine(foo.Peel());
            Console.WriteLine(unpeeledOrange.Peel());

            Banana banana = new Banana();

            List <IFruit> fruitBasket = new List <IFruit>();

            fruitBasket.Add(banana);
            fruitBasket.Add(foo);
            fruitBasket.ToArray();
        }
Beispiel #6
0
        public void FruitTest()
        {
            Orange orange         = new Orange(true);
            Orange unpeeledOrange = new Orange(false);

            Console.WriteLine(orange.IsPeeled);
            Console.WriteLine(unpeeledOrange.IsPeeled);

            Console.WriteLine(orange.Peel());
            Console.WriteLine(unpeeledOrange.Peel());

            Banana jake = new Banana();

            List <IFruit> fruitBasket = new List <IFruit>();

            fruitBasket.Add(jake);
            fruitBasket.Add(orange);
            fruitBasket.Add(unpeeledOrange);
        }