コード例 #1
0
ファイル: Lottery.cs プロジェクト: ronmelcuba10/lottoApp
        public List <NumberOccurrence> GetAnyNumbersOrdered(Drawings drawings, bool leastFirst, bool byNumbers, Action <Numbers> action, int[] nums, int maxNum)
        {
            // gets all the ocurrences of all the numbers
            drawings.ForEach(action);

            NumberOccurrenceCollection noC = new NumberOccurrenceCollection();

            for (int i = 0; i < maxNum; i++)
            {
                noC.Add(new NumberOccurrence(i + 1, nums[i]));
            }

            return(leastFirst
                ? noC.OrderBy(n => byNumbers ? n.Number : n.Occurrence).ToList()
                : noC.OrderByDescending(n => byNumbers ? n.Number : n.Occurrence).ToList());
        }