コード例 #1
0
        public void CallingInterfaceMethods()
        {
            //new up an instance of an IFruite
            IFruit banana = new Orange();

            string output = banana.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {banana.Name} is peeled:" + banana.Peeled);
        }
コード例 #2
0
        public void CallingInterfaceMethods()
        {
            //New up an instance of an IFruit
            IFruit fruit = new Orange();

            string output = fruit.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {fruit.Name} is peeled: " + fruit.Peeled);
        }
コード例 #3
0
        public void CallingInterfaceMethods()
        {
            //New up an instance of an IFruit
            IFruit fruit = new Orange();    // control r r will automatically rename all instances (fruit)

            string output = fruit.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {fruit.Name} is peeled: " + fruit.Peeled);
        }
コード例 #4
0
        public void CallingInterfaceMethods()
        {
            // New up an instance of an Ifruit
            IFruit fruit = new Orange();    //calling just Ifruit props , not banana or orange
                                            // we can change new Banana to Orange or grape and get new output for everything
            string output = fruit.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {fruit.Name} is peeled: " + fruit.Peeled);

            var fruits = new Orange();  // but from here I can call orange sqeeze method, because "var" not Ifruit.

            fruits.Squeeze();
        }
コード例 #5
0
        public void OrangeTest()
        {
            Orange orange   = new Orange(true);
            Orange unOrange = new Orange(false);

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

            string SmallerNum(string n1, string n2)
            {
                int result = String.Compare(n1, n2);

                return(result <= 0 ? n1 : n2);
            }

            Console.WriteLine(SmallerNum("21", "56"));
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: Evan-Lacy/SDLessons69
        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();
        }
コード例 #8
0
ファイル: UnitTest1.cs プロジェクト: sayorinde/SDLessons69
        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);
        }