public RatingCombiner(string fileContent, int maxNumber)
        {
            int[][] intArrayFromFile = CropArray(ReduceArrayByPushingOutNulls(CreateIntArrayFromString(fileContent)));
            Tables.allNumbersCount = Calculators.CalculateTotalNumbersCount(intArrayFromFile[0].Length, intArrayFromFile.Length);

            int[] numbersCounted = Calculators.CountEverySingleNumber(maxNumber, intArrayFromFile);

            view = new DataView(Tables.PopulateDataTable(maxNumber, numbersCounted,
                                                         Tables.ETableType.rate, new string[] { "Number", "Count", "Rate" }));
            view.Sort = "Count DESC";
        }
Ejemplo n.º 2
0
        public static DataTable PopulateDataTable(int maxNumber, int[] inputArray, ETableType tableType, string[] columnNames)
        {
            DataTable table = CreateTable(tableType, columnNames);
            DataRow   row;

            for (int i = 0; i < maxNumber; i++)
            {
                if (inputArray[i] != 0)
                {
                    row = table.NewRow();
                    row[columnNames[0]] = i + 1;
                    row[columnNames[1]] = inputArray[i];
                    if (tableType == ETableType.rate)
                    {
                        row[columnNames[2]] = $"{Calculators.CalculatePercentRate(inputArray[i], allNumbersCount)}";
                        //row[columnNames[2]] = $"{Calculators.CalculatePercentRate(inputArray[i], allNumbersCount)}%";
                    }
                    table.Rows.Add(row);
                }
            }
            return(table);
        }