Example #1
0
        public static ILifecycle GetLifecycle(this PoultryEnum poultryEnum, List <IPoultry> poultryList)
        {
            switch (poultryEnum)
            {
            case PoultryEnum.None:
                throw new Exception("none.is.notvalid");

            case PoultryEnum.Rabbit:
                return(new RabbitLifecycle(poultryList));

            default:
                throw new Exception("invalid.poultryenum");
            }
        }
Example #2
0
 public void AddPoultry(PoultryEnum poultryEnum, GenderEnum genderEnum)
 {
     PoultryList.Add(new Poultry()
     {
         Age                = 0,
         PoultryEnum        = poultryEnum,
         GenderEnum         = genderEnum,
         isPregnant         = false,
         isPostPartumPeriod = false,
         AverageLifeTime    = Statistics.averageLifeTime,
         LoseofFertility    = Statistics.loseofFertility,
         PercentageofBorn   = Statistics.percentageofBorn,
         TimeofPregnancy    = Statistics.timeofPregnancy,
     });
 }
Example #3
0
        public bool IsDeath(PoultryEnum poultryEnum, int age)
        {
            int deathAge = Statistics.RandomIntValue();

            if (poultryEnum == PoultryEnum.Rabbit)
            {
                if (age < 6)
                {
                    return(false);
                }
                else if (age >= 6 && age <= 12)
                {
                    if (deathAge <= 8)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else if (age > 12 && age < Statistics.averageLifeTime)
                {
                    if (deathAge >= 4)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }