コード例 #1
0
        /// <summary>
        /// Model the price of each present cohort for a given breed
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IEnumerable <AnimalPriceGroup> GetAnimalPrices(AnimalPricing parent)
        {
            List <AnimalPriceGroup> prices = new List <AnimalPriceGroup>();

            double sire_price = 0;
            int    row        = -1;

            foreach (string cohort in RumNumbers.RowNames)
            {
                row++;
                if (RumNumbers.GetData <double>(row, RumActiveID) != 0)
                {
                    if (!cohort.ToLower().Contains("sire"))
                    {
                        sire_price = RumPrices.GetData <double>(row, RumActiveID);
                    }

                    var group = new AnimalPriceGroup(parent)
                    {
                        Name  = cohort,
                        Value = RumPrices.GetData <double>(row, RumActiveID)
                    };

                    // Filter cohort based on gender
                    group.Add(new RuminantFilter(group)
                    {
                        Name      = "GenderFilter",
                        Parameter = 2,
                        Value     = cohort.ToLower().Contains("f") ? "Female" : "Male"
                    });

                    // Filter cohort based on age
                    group.Add(new RuminantFilter(group)
                    {
                        Name      = "AgeFilter",
                        Parameter = 3,
                        Operator  = 5,
                        Value     = RumAges.GetData <string>(row, RumActiveID)
                    });

                    prices.Add(group);
                }
            }
            parent.SirePrice = sire_price;

            return(prices);
        }
コード例 #2
0
        /// <summary>
        /// Model all present cohorts of a given ruminant breed
        /// </summary>
        public IEnumerable <RuminantTypeCohort> GetCohorts(RuminantInitialCohorts parent)
        {
            List <RuminantTypeCohort> cohorts = new List <RuminantTypeCohort>();

            int row = -1;

            foreach (string cohort in RumNumbers.RowNames)
            {
                row++;
                if (RumNumbers.GetData <string>(row, RumActiveID) != "0")
                {
                    // Check gender
                    int gender = 0;
                    if (cohort.Contains("F"))
                    {
                        gender = 1;
                    }

                    // Check suckling
                    bool suckling = false;
                    if (cohort.Contains("Calf"))
                    {
                        suckling = true;
                    }

                    // Check breeding sire
                    bool sire = false;
                    if (cohort.Contains("ires"))
                    {
                        sire = true;
                    }

                    cohorts.Add(new RuminantTypeCohort(parent)
                    {
                        Name     = cohort,
                        Gender   = gender,
                        Age      = (int)Math.Ceiling(RumAges.GetData <double>(row, RumActiveID)),
                        Number   = (int)Math.Ceiling(RumNumbers.GetData <double>(row, RumActiveID)),
                        Weight   = RumWeights.GetData <double>(row, RumActiveID),
                        Suckling = suckling,
                        Sire     = sire
                    });
                }
            }

            return(cohorts);
        }