Exemplo n.º 1
0
 public bool TakeEat(ICanEat ace)
 {
     if (FoodRec > 0)
     {
         ace.Hunger.Hung += FoodRec;
         FoodRec          = 0;
     }
     return(true);
 }
Exemplo n.º 2
0
 public bool TakeEat(ICanEat anm)
 {
     if (!Health.alive)
     {
         if (FoodRec > 2)
         {
             anm.Hunger.Hung += 2;
             FoodRec         -= 2;
         }
         else
         {
             anm.Hunger.Hung += FoodRec;
             FoodRec          = 0;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void Expected()
        {
            Patterns.AbstractFactory.AbstractFactory meatWolfFactory = new MeatWolfFactory()
                                                                       .SetMeatAnimal(new Sheep("John"))
                                                                       .SetMeatWeight(1.5)
                                                                       .SetWolfName("Jim");
            Assert.Equal(0, meatWolfFactory.UniqId);
            ICanEat wolf = meatWolfFactory.BuildCanEat();

            Assert.Equal("Wolf Jim", wolf.Name);
            IFood sheepMeat = meatWolfFactory.BuildFood();

            Assert.Equal("Wolf Jim", wolf.Name);
            Assert.Equal(1.5, sheepMeat.Weight);
            Assert.Equal("Sheep John meat", sheepMeat.Name);
            wolf.Eat(sheepMeat);
            Assert.Equal(0, sheepMeat.Weight);

            Patterns.AbstractFactory.AbstractFactory gasVehicleFactory = new GasVehicleFactory()
                                                                         .SetGasBrand("Bas")
                                                                         .SetGasWeight(1000)
                                                                         .SetVehicleBrand("GrrMotor")
                                                                         .SetVehicleConsumption(20)
                                                                         .SetVehicleModel("o0O");
            Assert.Equal(1, gasVehicleFactory.UniqId);
            ICanEat vehicle = gasVehicleFactory.BuildCanEat();

            Assert.Equal("Vehicle «o0O», GrrMotorⓒ", vehicle.Name);
            IFood gas = gasVehicleFactory.BuildFood();

            Assert.Equal("Vehicle «o0O», GrrMotorⓒ", vehicle.Name);
            Assert.Equal("Gas «Bas»", gas.Name);
            Assert.Equal(1000.0, gas.Weight);
            vehicle.Eat(gas);
            Assert.Equal(980.0, gas.Weight);

            NotEqualLink();
        }
 public MeatWolfFactory SetMeatAnimal(ICanEat animal)
 {
     meat.Animal     = animal;
     isReadyToBuild |= 0b1;
     return(this);
 }
 public void AddToList(ICanEat caneat)
 {
     throw new NotImplementedException();
 }