Esempio n. 1
0
 void MakeFlight(IFlyable dingetje)
 {
     dingetje.LiftOff();
     dingetje.Fly();
     dingetje.Fly();
     dingetje.Fly();
     dingetje.Land();
     Console.WriteLine();
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();
            car.Company = "현대";

            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            TestClass t = new TestClass();

            t.Run();

            IWalkable w = t as IWalkable;

            w.Run();

            IRunnable r = t as IRunnable;

            r.Run();
        }
Esempio n. 3
0
 public static void GoToFlightSchool(IFlyable flyingStudent)
 {
     Console.Write(flyingStudent.ToString());
     Console.WriteLine(" says:");
     flyingStudent.Fly();
     Console.WriteLine();
 }
Esempio n. 4
0
        public Duck 飛行()
        {
            if (FlyBehavior == null)
            {
                Console.WriteLine("未裝有任何具有飛行能力的道具,所以不會飛");
            }
            else
            {
                FlyBehavior.Fly();
            }

            return(this);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnble = car as IRunnable;
            IFlyable  flyable = car as IFlyable;

            runnble.Run();
            flyable.Fly();
        }
Esempio n. 6
0
        public override bool IsMovable(IBody obj)
        {
            if (obj is IFlyable)
            {
                IFlyable flyable = (IFlyable)obj;

                if (flyable.FlyingHeight > _height)
                {
                    flyable.Fly();
                }
            }

            return(false);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            FlyingCar clsCar = new FlyingCar();

            clsCar.Fly();
            clsCar.Run();

            IRunnable iRunable = clsCar as IRunnable;

            iRunable.Run();

            IFlyable iFlyable = clsCar as IFlyable;

            iFlyable.Fly();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();
            car.Company = "현대";

            IRunnable runnable = car; // as IRunnable; 생략 가능

            runnable.Run();

            IFlyable flyable = car; // as IFlyable; 생략 가능

            flyable.Fly();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();
            car.Company = "현대";

            IRunnable runnable = car as IRunnable;      //형변환, 형변환 안되면 null값 들어감

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable; // 강제 형변환 as를 통해 car(class FlyingCar, IRunnable, IFlyable)을

            // IRunnable로 변환시킨다.
            runnable.Run();

            IFlyable flyable = car as IFlyable;    // as를 통해 car(IRunnable)을

            flyable.Fly();                         // IFlyable로 변환시킨다.
        }
Esempio n. 11
0
        static void MultiInterfaceInheritance()
        {
            WriteLine("\nMultiInterfaceInheritance()");

            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            IFormattableLogger logger = new ConsoleLogger2();

            logger.WriteLog("{0} + {1} = {2}", 1, 1, 2);

            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable;
            IFlyable  flyable  = car as IFlyable;

            runnable.Run();
            flyable.Fly();
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            // 다중 상속받은 클래스
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();
            car.Company = "현대";

            // 부모 인터페이스
            // 부모연산자인 IRunnable에 as 연산자를 사용하여 자식 클래스인 car에 캐스팅 하였다.
            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            // this car can't fly
            IRunnable runnable = car as IRunnable;

            runnable.Run();

            // this car can't run
            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            return;
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            car.Company    = "Naver";
            car.HorsePower = 12.4f;
            car.Year       = 1234;
            WriteLine($"{car.Company} {car.HorsePower} {car.Year}");
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            MyVehicle myVehicle = new MyVehicle();

            myVehicle.car.Run();
            myVehicle.plane.Fly();
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Console.WriteLine("드론카!");

            DroneCar dreamCar = new DroneCar();

            dreamCar.Run();
            dreamCar.Fly();

            Console.WriteLine("자동차로 변경(interface)");
            IRunnable car = dreamCar;

            car.Run();
            //car.Fly(); // error

            Console.WriteLine("비행기로 변경(interface)");
            IFlyable plane = dreamCar;

            plane.Fly();
            //plane.Run(); // error
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            Duck    duck    = new Duck();
            Penguin penguin = new Penguin();
            Dolphin dolphin = new Dolphin();

            duck.Move();
            duck.Eat();

            penguin.Move();
            penguin.Eat();

            dolphin.Move();
            dolphin.Eat();


            IFlyable duck2 = duck as IFlyable;

            duck2.Fly();

            IWalkable penguin2 = penguin as IWalkable;

            penguin2.Walk();

            ISwimable dolphin2 = dolphin as ISwimable;

            dolphin2.Swim();


            string direction = Direction.down.ToString();

            duck.Move(direction);

            direction = Direction.up.ToString();
            penguin.Move(direction);


            Console.ReadKey();
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            ClimateMonitor monitor = new ClimateMonitor(new FileLogger("MyLog.txt"));

            monitor.start();

            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable;

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            AbstactBase obj = new Derived();

            obj.AbstarctMethodA();
            obj.PublicMethodA();
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            FlyingCar car = new FlyingCar();

            car.Run();
            car.Fly();

            IRunnable runnable = car as IRunnable; // 이미 구현했기때문에 as IRunnable 생략가능

            runnable.Run();

            IFlyable flyable = car as IFlyable;

            flyable.Fly();

            Testclass test = new Testclass();

            IRunnable run = test as IRunnable;

            test.Run();
            IWalkAble walk = test as IWalkAble;

            test.walk();
        }
Esempio n. 21
0
 static void Flying(IFlyable flyer)
 {
     flyer.Fly();
 }
Esempio n. 22
0
 static void Flying(IFlyable flyable)
 {
     flyable.Fly();
 }
Esempio n. 23
0
 public void PerformFly()
 {
     flyable.Fly();
 }
Esempio n. 24
0
 private static void DoFly(IFlyable duck)
 {
     duck.Fly();
 }
Esempio n. 25
0
File: Duck.cs Progetto: Denizzi/dp
 public void PerformFly()
 {
     _flyBehaviour.Fly();
 }
Esempio n. 26
0
 public void Fly()
 {
     _flyable.Fly();
 }
Esempio n. 27
0
 public void PerformFly()
 {
     FlyBehavior.Fly();
 }
Esempio n. 28
0
 // Герой летать
 public void Fly()
 {
     flyBehavior.Fly();
 }
Esempio n. 29
0
 public string GetFlyType()
 {
     return(_flyType.Fly());
 }
Esempio n. 30
0
 //调用行为
 public void Fly() => _fly.Fly();