Beispiel #1
0
        /// <summary>
        /// The by interval execute.
        /// </summary>
        /// <returns>
        /// The <see cref="LotteryModel"/>.
        /// </returns>
        public LotteryModel ByIntervalExecute()
        {
            var actual = this.NumberSections.Where(x => x.ActualNumber == this.lotteryCollection.Last().Numbers.First());

            LotteryModel lm = new LotteryModel(lotteryRule);

            for (int i = 0; i < lotteryRule.PiecesOfDrawNumber; i++)
            {
                int max = 0;
                List <IOrderedEnumerable <SpecifyNumber> > spec = actual.Select(x => x.SpecifyNumberList.OrderByDescending(xy => xy.Pieces)).ToList();
                List <int>    maxCount = spec[0].Select(x => x.Pieces).OrderByDescending(x => x).ToList();
                SpecifyNumber getSec   = spec[0].First(x => x.Pieces == maxCount[max]);

                while (true)
                {
                    if (lm.Numbers.Contains(getSec.NextNumber))
                    {
                        max++;
                        getSec = spec[0].First(x => x.Pieces == maxCount[max]);
                    }
                    else
                    {
                        if (lm.Numbers.Count == 0)
                        {
                            break;
                        }
                        if (getSec.NextNumber > lm.Numbers.Max())
                        {
                            break;
                        }
                        max++;
                        getSec = spec[0].First(x => x.Pieces == maxCount[max]);
                    }
                }

                var getAf = getSec.NextNumber;
                lm.Numbers.Add(getAf);
                actual = this.NumberSections.Where(x => x.ActualNumber == getAf);
            }

            return(lm);
        }
Beispiel #2
0
        /// <summary>
        /// The by occurrence execute.
        /// </summary>
        /// <returns>
        /// The <see cref="LotteryModel"/>.
        /// </returns>
        public LotteryModel ByOccurrenceExecute()
        {
            LotteryModel lm = new LotteryModel(lotteryRule);

            var    getSections    = this.NumberSections.Last(x => this.lotteryCollection.Last().Numbers.First() == x.ActualNumber);
            Random random         = new Random();
            int    start2         = random.Next(0, getSections.SpecifyNumberList.Count);
            var    generateNumber = (SpecifyNumber)getSections.SpecifyNumberList[start2].Clone();

            lm.AddNumber(generateNumber.NextNumber);
            for (int k = 0; k < lotteryRule.PiecesOfDrawNumber - 1; k++)
            {
                getSections = this.NumberSections.First(x => lm.Numbers.Last() == x.ActualNumber);

                while (true)
                {
                    random = new Random();
                    if (getSections.SpecifyNumberList.Count > 10)
                    {
                        start2         = random.Next(0, getSections.SpecifyNumberList.Count);
                        generateNumber = (SpecifyNumber)getSections.SpecifyNumberList[start2].Clone();
                    }
                    else
                    {
                        start2         = GetRandomNumber(lotteryRule);
                        generateNumber = new SpecifyNumber(start2);
                    }

                    if (!lm.Numbers.Contains(generateNumber.NextNumber))
                    {
                        break;
                    }
                }

                lm.AddNumber(generateNumber.NextNumber);
            }

            return(lm);
        }