void MakeFlight(IFlyable dingetje) { dingetje.LiftOff(); dingetje.Fly(); dingetje.Fly(); dingetje.Fly(); dingetje.Land(); Console.WriteLine(); }
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(); }
public static void GoToFlightSchool(IFlyable flyingStudent) { Console.Write(flyingStudent.ToString()); Console.WriteLine(" says:"); flyingStudent.Fly(); Console.WriteLine(); }
public Duck 飛行() { if (FlyBehavior == null) { Console.WriteLine("未裝有任何具有飛行能力的道具,所以不會飛"); } else { FlyBehavior.Fly(); } return(this); }
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(); }
public override bool IsMovable(IBody obj) { if (obj is IFlyable) { IFlyable flyable = (IFlyable)obj; if (flyable.FlyingHeight > _height) { flyable.Fly(); } } return(false); }
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(); }
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(); }
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(); }
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로 변환시킨다. }
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(); }
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(); }
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(); }
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; }
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}"); }
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(); }
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 }
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(); }
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(); }
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(); }
static void Flying(IFlyable flyer) { flyer.Fly(); }
static void Flying(IFlyable flyable) { flyable.Fly(); }
public void PerformFly() { flyable.Fly(); }
private static void DoFly(IFlyable duck) { duck.Fly(); }
public void PerformFly() { _flyBehaviour.Fly(); }
public void Fly() { _flyable.Fly(); }
public void PerformFly() { FlyBehavior.Fly(); }
// Герой летать public void Fly() { flyBehavior.Fly(); }
public string GetFlyType() { return(_flyType.Fly()); }
//调用行为 public void Fly() => _fly.Fly();