Ejemplo n.º 1
0
            public static void Main()
            {
                Implement Imp    = new Implement();
                Animal    animal = new Animal();


                Carnivorous cn = new Carnivorous();
                Herbivorous hb = new Herbivorous();

                Console.WriteLine("Call function with animal obj");
                Imp.callFunction(animal);


                Console.WriteLine("Call function with Carnivorous obj");
                Imp.callFunction(cn);//Decision is take during runttime--We can pass object of Base class Animal or any of its derived class

                //We can call Behaviour method of Child class only with child class object as it is not declared with Virtual keyword
                Console.WriteLine("Call function with Herbivorous obj");

                Imp.callFunction(hb);
                Birds bird = new Birds();

                //Imp.callFunction(bird);--Not possible....We can pass only animal class object or its dervived classes
                Console.WriteLine("Calling the Behaviour method with Carnivorous class obj");
                cn.Behaviour();

                Console.ReadLine();

                //Animal animal1;

                //animal1 = new Animal();
                //animal1.FoodHabits();
                //animal.Behaviour();

                //animal1 = new Carnivorous();
                //animal1.FoodHabits();
                //animal1.Behaviour();

                //animal1= new Herbivorous();
                //animal1.FoodHabits();//Virtual method will call the corresponding method of what is beeing passed
                //animal1.Behaviour();//Normal method Always call the method of Base class only

                ////Carnivorous car = (Carnivorous)new Animal();--Error...Only parent class object can be used for instantiating child class and Viceversa is not possible
            }
Ejemplo n.º 2
0
        public override void InitializeAgent()
        {
            base.InitializeAgent();
            LivingBeing = new Carnivorous(50, 0, 0, 50, 0, 10);

            eatCounter          = Metrics.CreateCounter("eatCarnivorous", "How many times carnivorous has eaten");
            reproductionCounter =
                Metrics.CreateCounter("reproductionCarnivorous", "How many times carnivorous has reproduced");
            cumulativeRewardGauge =
                Metrics.CreateGauge("cumulativeRewardCarnivorous", "Cumulative reward of carnivorous");
            lifeGainGauge =
                Metrics.CreateGauge("lifeGainCarnivorous", "Life gain on eat of carnivorous");
            rewardOnActGauge =
                Metrics.CreateGauge("rewardOnActCarnivorous", "Reward on act carnivorous");
            rewardOnEatGauge =
                Metrics.CreateGauge("rewardOnEatCarnivorous", "Reward on eat carnivorous");
            rewardOnReproduceGauge =
                Metrics.CreateGauge("rewardOnReproduceCarnivorous", "Reward on reproduce carnivorous");
            speedGauge =
                Metrics.CreateGauge("speedCarnivorous", "Speed carnivorous");
        }
Ejemplo n.º 3
0
        private void AddAnimal_Click(object sender, EventArgs e)
        {
            if (NameIn.Text.Trim() != String.Empty)
            {
                FeedType feedType = null;
                switch (FeedTypesList.SelectedItem)
                {
                case FeedTypes.Herbivorous:
                    feedType = new Herbivorous();
                    break;

                case FeedTypes.Omnivorous:
                    feedType = new Omnivorous();
                    break;

                case FeedTypes.Carnivorous:
                    feedType = new Carnivorous();
                    break;
                }
                switch (AnimalTypesList.SelectedItem)
                {
                case Animals.Bird:
                    Animal = new Bird(NameIn.Text.Trim(), DateOfBirthIn.Value, feedType);
                    break;

                case Animals.Fish:
                    Animal = new Fish(NameIn.Text.Trim(), DateOfBirthIn.Value, feedType);
                    break;

                case Animals.Mammal:
                    Animal = new Mammal(NameIn.Text.Trim(), DateOfBirthIn.Value, feedType);
                    break;
                }
                Handled = true;
                Close();
            }
        }
Ejemplo n.º 4
0
 public RunningAction(Running trait, Carnivorous carnivorous)
     : base(trait)
 {
     this.Carnivorous = carnivorous;
 }
Ejemplo n.º 5
0
 public TailLossAction(TailLoss trait, Trait tailTrait, Carnivorous carnivorous)
     : base(trait)
 {
     this.TailTrait   = tailTrait;
     this.Carnivorous = carnivorous;
 }
Ejemplo n.º 6
0
 public override void InitializeAgent()
 {
     LivingBeing = new Carnivorous(99, 0, 20, 99, 0);
     rayPer      = GetComponent <RayPerception>();
 }