protected Duck() { _fly = new FlyClass(); _quack = new QuackClass(); _walk = new WalkClass(); _swim = new SwimClass(); }
public TurkeyCock(IFly f, ICluck c, IWalk w, ISwim s) { _fly = f; _cluck = c; _walk = w; _swim = s; }
public List <IBaseDuck> CreatList() { Random rnd = new Random(); List <IBaseDuck> _baseDucks = new List <IBaseDuck>(); for (int i = 0; i < 6; i++) { IBaseDuck duck = null; if (rnd.Next(0, 10) % 2 == 0) { IFly F = ReturnFly(rnd.Next(0, 2)); IQuick Q = ReturnQuick(rnd.Next(0, 2)); IComposition C = ReturnComposition(rnd.Next(0, 3)); duck = new Duck(F, Q, C); } else { Turkey turkey; IKudah K = ReturnKudah(rnd.Next(0, 10) % 2); IFly2 F = ReturnFly2(rnd.Next(0, 10) % 2); IComposition C = ReturnComposition(rnd.Next(0, 3)); turkey = new Turkey(F, K, C); duck = new CreateDuck(turkey); } _baseDucks.Add(duck); } return(_baseDucks); }
public Bird(string Name, IMakeNoise noiseMaker, IGenerateHeat generator, IFly flyer) { this.Name = Name; this.noiseMaker = noiseMaker; this.generator = generator; this.flyer = flyer; }
public Duck(Idisplay display, ISwim swim, IFly fly, IKuak kuak) : this(display, swim, fly) { if (kuak != null) { _kuak = kuak; } }
public Animal(double wight, string favoriteFood, string sound, IFly type) { Sound = sound; Weight = Weight; FavoriteFood = favoriteFood; FlyingStrategy = type; }
public Animal(string Name, IMakeNoise noiseMaker, IGenerateHeat generator, IFly fly) { this.Name = Name; this.noiseMaker = noiseMaker; this.generator = generator; this.fly = fly; }
public ADuck(IFly f, IQuack q, ISwimm s, IGo g) { _fly = f; _quack = q; _swimm = s; _go = g; }
public ADuck() { _fly = new DucksFly(); _quack = new DucksQuack(); _swimm = new DucksSwimm(); _go = new DucksGo(); }
public ATurkeyCock(IFly f, ICluck c, ISwimm s, IGo g) { _fly = f; _cluck = c; _swimm = s; _go = g; }
public Duck(IFly f, IQuack q, IWalk w, ISwim s) { _fly = f; _quack = q; _walk = w; _swim = s; }
protected BaseDuck(IFly fly, IQuack quack, ISwim swim, IWalk walk, IName name) { _fly = fly; _quack = quack; _swim = swim; _walk = walk; _name = name; }
protected BaseTurkey(IFly fly, IGobble gobble, ISwim swim, IWalk walk, IName name) { _fly = fly; _gobble = gobble; _swim = swim; _walk = walk; _name = name; }
static void Main(string[] args) { #region OOP //Human amanda = new Human(); Student jeff = new Student("Jeff", "Jeff", 1, "401-dotnet-d2"); int x = 5; //StackHeap(x,jeff); Console.WriteLine(x); Console.WriteLine($"Jeff's age is: {jeff.Age}"); Human enrique = new Student("Enrique", "Kike", 2, "401-dotnet-d9"); //jeff.Live(); // Vinicio - somehow .NET knows that enrique is actually a student // and calls the right implementation for Live // POLYMORPHISM //enrique.Live(); Athlete mike = new Athlete("Mike", "Mike", 5, 3000, 2); CFStudent karina = new CFStudent("Karina", "Karina", 1); //PolymorphismInAction(new Human[] { jeff, enrique, mike, karina }); //karina.Think(); #endregion #region Interfaces DanceParty(karina, mike); #endregion #region Enums int January = 1; int February = 2; Month m = Month.April; //WorkingWithMonths(Month.April ,84884854); #endregion // IFly fly = new Airplane(); Airplane airplane = new Airplane(); IDrivable driveable = airplane; IFly iFly = airplane; Console.WriteLine($"is airplane an IFly? {airplane is IFly}"); Console.WriteLine($"is airplane an IDriveable? {airplane is IDrivable}"); Console.WriteLine($"is airplane an Airplane? {airplane is Airplane}"); Console.WriteLine($"is airplane an IDance? {airplane is IDance}"); }
private void Start() { body = GetComponent <Rigidbody2D>(); collider = GetComponent <BoxCollider2D>(); landPosition = transform.position; flySystem = new FlySystem(); groundCheckSystem = new GroundCheckSystem(); flySystem.SetupForces(_initialImpulse, _thrusterForce); flySystem.SetupFuel(_maxFuel, _impulseCost); }
public static Message ToMessage(this IFly fly, bool sending) { var serializedArray = fly.Serialize(); var modified = sending ? serializedArray.Skip(1) : serializedArray; var array = modified.Concat(new object[] { 0u }).ToArray(); return(Message.Create(Type, array)); }
private void btnShout_Click(object sender, EventArgs e) { MachineCat mcat = new MachineCat("小叮当"); StoneMonkey wukong = new StoneMonkey("孙悟空"); SuperMan sman = new SuperMan(); IFly[] fliers = new IFly[4]; fliers[0] = mcat; fliers[1] = wukong; fliers[2] = sman; //for (int i = 0; i < 3; i++) //{ // fliers[i].Fly(); //} ArrayList arrayListAnimal = new ArrayList(); arrayListAnimal.Add(mcat); arrayListAnimal.Add(wukong); arrayListAnimal.Add(sman); //arrayListAnimal.Add(123); //arrayListAnimal.Add("Hello world"); //for (int i = 0; i < arrayListAnimal.Count; i++) //{ // MessageBox.Show(((IFly)arrayListAnimal[i]).Fly()); //} List <IFly> flyList = new List <IFly>(); flyList.Add(new MachineCat()); flyList.Add(new StoneMonkey()); flyList.Add(new SuperMan()); //for (int i = 0; i < flyList.Count; i++) //{ // MessageBox.Show(flyList[i].Fly()); //} //foreach (IFly fly in flyList) //{ // fly.Fly(); //} //int a = 123; //object o = (object) a; //int b = (int) o; }
public Duck(Idisplay display, ISwim swim, IFly fly) { if (display != null) { _display = display; } if (swim != null) { _swim = swim; } if (fly != null) { _fly = fly; } }
private void btnShout_Click(object sender, EventArgs e) { MachineCat mcat = new MachineCat("小叮当"); StoneMonkey wukong = new StoneMonkey("孙悟空"); SuperMan sman = new SuperMan(); IFly[] fliers = new IFly[4]; fliers[0] = mcat; fliers[1] = wukong; fliers[2] = sman; //for (int i = 0; i < 3; i++) //{ // fliers[i].Fly(); //} ArrayList arrayListAnimal = new ArrayList(); arrayListAnimal.Add(mcat); arrayListAnimal.Add(wukong); arrayListAnimal.Add(sman); //arrayListAnimal.Add(123); //arrayListAnimal.Add("Hello world"); //for (int i = 0; i < arrayListAnimal.Count; i++) //{ // MessageBox.Show(((IFly)arrayListAnimal[i]).Fly()); //} List<IFly> flyList = new List<IFly>(); flyList.Add(new MachineCat()); flyList.Add(new StoneMonkey()); flyList.Add(new SuperMan()); //for (int i = 0; i < flyList.Count; i++) //{ // MessageBox.Show(flyList[i].Fly()); //} //foreach (IFly fly in flyList) //{ // fly.Fly(); //} //int a = 123; //object o = (object) a; //int b = (int) o; }
public static void MainTest() { // Cannot resolve symbol 'Fly' // new Superman().Fly(); IFly fly = new Superman(); fly.Fly(); fly = new MonkeyKing(); fly.Fly(); // Cannot access protected method 'GetDefaultName' here // IFly.GetDefaultName().Dump(); IFly.GetPublicName().Dump(); }
/// <summary> /// Отримати всі ТЗ які вміють літати /// </summary> /// <param name="arrVehicle">Масив транспортних засібів</param> /// <param name="arrProcess">Масив ТЗ які літають</param> public static void GetIFlyFromArrVeh(CVehicle[] arrVehicle, out IFly[] arrProcess) { //var neededObjects = arrVehicle.Where(x => x is IFly).ToArray(); IFly[] masFly = new IFly[arrVehicle.Length]; int i = 0; foreach (var item in arrVehicle) { if (item is IFly) { masFly[i++] = item as IFly; } } Array.Resize(ref masFly, i); arrProcess = masFly; }
static void Main(string[] args) { Duck duck = new Duck() { Height = 180 }; duck.Fly(); duck.Move(); Console.WriteLine("Hello World!"); IFly ifl = duck; ifl.Move(); MandarinDuck mDuck = new MandarinDuck(); mDuck.Move(); mDuck.Fly(); }
public IFly Fly(BirdType b) { IFly fly = null; switch (b) { case BirdType.Glede: fly = new GledeFly(); break; case BirdType.Bird: fly = new BirdFly(); break; default: throw new Exception("12323"); } return(fly); }
static void Main(string[] args) { Duck duck = new Duck() { Height = 189 }; duck.Fly(); duck.Move(); IFly fly = duck; fly.Move(); (duck as ISwim).Move(); // ISwim.Move Duck mDuck = new MandarinDuck(); mDuck.Fly(); // Duck.Fly() (mDuck as MandarinDuck).Fly(); }
public IBaseDuck[] CreatArray() { Random rnd = new Random(); IBaseDuck[] _baseDucks = new IBaseDuck[6]; for (int i = 0; i < 6; i++) { IBaseDuck duck = null; if (rnd.Next(0, 10) % 2 == 0) { IFly F = ReturnFly(rnd.Next(0, 2)); IQuick Q = ReturnQuick(rnd.Next(0, 2)); IComposition C = ReturnComposition(rnd.Next(0, 3)); duck = new Duck(F, Q, C); } else { Turkey turkey; IKudah K = ReturnKudah(rnd.Next(0, 10) % 2); IFly2 F = ReturnFly2(rnd.Next(0, 10) % 2); IComposition C = ReturnComposition(rnd.Next(0, 3)); turkey = new Turkey(F, K, C); duck = new CreateDuck(turkey); } _baseDucks[i] = duck; } return(_baseDucks); }
public DIOperateController( IOperationTransient transient, IOperationScoped scope, IOperationSingleton singleton, IJob job, IOperationSingletonInstance instance, OperationService operationService, Service1 service1, ISomeService someService, Service3 service3, IFly fly ) { this._transient = transient; this._scope = scope; this._singleton = singleton; this._job = job; this._instance = instance; this._operationService = operationService; this._service1 = service1; this._someService = someService; this._service3 = service3; this._fly = fly; }
public Duck(IFly _fly, IQuack _quack, IWalk _walk) : base(_fly, _quack, _walk) { }
public HasDependencyTest(IFly fly) { _fly = fly; }
public duck(IQuackBehaviour quack, IFly fly) { this.quackBehaviour = quack; this.flyBehaviour = fly; }
public void SetFlyingAbility(IFly newFlyType) { FlyingType = newFlyType; }
public ValuesController(IFly fly) { _fly = fly; }
public ATurkeyCock(IFly f) { _fly = f; }
public Bird(IFly flyBehaviour, ISpeak speakBehaviour, ISwim swimBehaviour) { FlyBehaviour = flyBehaviour; SpeakBehaviour = speakBehaviour; SwimBehaviour = swimBehaviour; }
public void SetFlyingAbility(IFly newFlyingType) { this.flyingType = newFlyingType; }
public Duck(IFly obj) { _flyobj = obj; }
protected Duck(IFly fly, IVoise voise) { this.fly = fly; this.voise = voise; }