コード例 #1
0
 public void InputIncorrectValue_ShouldThrowException()
 {
     Coordinates cellA = new Coordinates(-1, 0);
     Coordinates cellB = new Coordinates(0, -4);
 }
コード例 #2
0
 public void InputRightValue_ShouldWorkCorrectly()
 {
     Coordinates cell = new Coordinates(1, 1);
 }
コード例 #3
0
 public void InputBoundValue_ShouldWorkCorrectly()
 {
     Coordinates cellFirst = new Coordinates(0, 0);
 }
コード例 #4
0
ファイル: Matrix.cs プロジェクト: Hri100v/Telerik-Academy
        private Coordinates FindFirstEmptyTarget()
        {
            int rows = this.Field.GetLength(0);
            int columns = this.Field.GetLength(1);

            Coordinates newTarget = new Coordinates(0, 0);

            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < columns; col++)
                {
                    if (this.Field[row, col] == 0)
                    {
                        this.currentTargetIndex = 0;
                        newTarget.Row = row;
                        newTarget.Col = col;
                        return newTarget;
                    }
                }
            }

            return null;
        }
コード例 #5
0
ファイル: Matrix.cs プロジェクト: Hri100v/Telerik-Academy
        private void FillMatrix()
        {
            var target = new Coordinates(0, 0);
            var accumulate = 1;

            while (target != null)
            {
                this.Field[target.Row, target.Col] = accumulate;
                target = this.Walk(target) ?? this.FindFirstEmptyTarget();
                accumulate++;
            }
        }
コード例 #6
0
ファイル: Matrix.cs プロジェクト: Hri100v/Telerik-Academy
        private Coordinates Walk(Coordinates target)
        {
            for (int index = this.currentTargetIndex; index < NUMBERS_DIRECTIONS + this.currentTargetIndex; index++)
            {
                int newTargetIndex = index % NUMBERS_DIRECTIONS;
                Coordinates nextTarget = target + this.targetDirections[newTargetIndex];
                if (this.IsValidWalk(nextTarget))
                {
                    this.currentTargetIndex = newTargetIndex;
                    return nextTarget;
                }
            }

            return null;
        }
コード例 #7
0
ファイル: Matrix.cs プロジェクト: Hri100v/Telerik-Academy
        private bool IsValidWalk(Coordinates checkTarget)
        {
            int size = this.Size;

            return checkTarget.Row >= 0 && checkTarget.Row < size &&
                    checkTarget.Col >= 0 && checkTarget.Col < size &&
                    this.Field[checkTarget.Row, checkTarget.Col] == 0;
        }