Esempio n. 1
0
        private static FieldData _locate(int[][] input)
        {
            var xLength = input.Length;
            var yLength = input.Max(x => x.Length);
            var result  = new FieldData(xLength, yLength);

            for (int row = 0; row < xLength; row++)
            {
                for (int column = 0; column < yLength; column++)
                {
                    if (input[row].Length < column)
                    {
                        throw new ArgumentException("Ungleiche Spaltenlängen gefunden; Fläche ist kein Rechteck.");
                    }

                    switch (input[row][column])
                    {
                    case 0:
                        continue;

                    case 1:
                        result.SetOne(new Point(row, column));
                        break;

                    case 2:
                        result.AddTwo(new Point(row, column));
                        break;

                    default:
                        throw new ArgumentException("Ungültiger Wert gefunden: " + input[row][column]);
                    }
                }
            }
            return(result);
        }