Beispiel #1
0
 void MakeFlight(IFlyable dingetje)
 {
     dingetje.LiftOff();
     dingetje.Fly();
     dingetje.Fly();
     dingetje.Fly();
     dingetje.Land();
     Console.WriteLine();
 }
Beispiel #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();
        }
Beispiel #3
0
 public static void GoToFlightSchool(IFlyable flyingStudent)
 {
     Console.Write(flyingStudent.ToString());
     Console.WriteLine(" says:");
     flyingStudent.Fly();
     Console.WriteLine();
 }
Beispiel #4
0
        public Duck 飛行()
        {
            if (FlyBehavior == null)
            {
                Console.WriteLine("未裝有任何具有飛行能力的道具,所以不會飛");
            }
            else
            {
                FlyBehavior.Fly();
            }

            return(this);
        }
Beispiel #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();
        }
Beispiel #6
0
        public override bool IsMovable(IBody obj)
        {
            if (obj is IFlyable)
            {
                IFlyable flyable = (IFlyable)obj;

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

            return(false);
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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로 변환시킨다.
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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;
        }
Beispiel #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}");
        }
Beispiel #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();
        }
Beispiel #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
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #21
0
 static void Flying(IFlyable flyer)
 {
     flyer.Fly();
 }
Beispiel #22
0
 static void Flying(IFlyable flyable)
 {
     flyable.Fly();
 }
Beispiel #23
0
 public void PerformFly()
 {
     flyable.Fly();
 }
Beispiel #24
0
 private static void DoFly(IFlyable duck)
 {
     duck.Fly();
 }
Beispiel #25
0
 public void PerformFly()
 {
     _flyBehaviour.Fly();
 }
Beispiel #26
0
 public void Fly()
 {
     _flyable.Fly();
 }
Beispiel #27
0
 public void PerformFly()
 {
     FlyBehavior.Fly();
 }
Beispiel #28
0
 // Герой летать
 public void Fly()
 {
     flyBehavior.Fly();
 }
Beispiel #29
0
 public string GetFlyType()
 {
     return(_flyType.Fly());
 }
Beispiel #30
0
 //调用行为
 public void Fly() => _fly.Fly();