Пример #1
0
        private static void GetNextTowartTest(Position position, Direction direction, Position result)
        {
            //Act
            var nextPos = position.GetNextTowards(direction);

            //Assert
            Assert.AreEqual(result, nextPos);
        }
Пример #2
0
 private void Init()
 {
     for (int rowIdx = 0; rowIdx < boardGrid.GetLength(0); rowIdx++)
     {
         for (int colIdx = 0; colIdx < boardGrid.GetLength(1); colIdx++)
         {
             var pos = new Position(rowIdx, colIdx);
             boardGrid[rowIdx, colIdx] = new Cell(this, pos);
         }
     }
 }
Пример #3
0
 public IPosition GetNextTowards(Direction direction)
 {
     var result = new Position(this);
     switch (direction)
     {
         case Direction.Left:
             result.Row--;
             break;
         case Direction.Right:
             result.Row++;
             break;
         case Direction.Up:
             result.Col++;
             break;
         case Direction.Down:
             result.Col--;
             break;
         default:
             throw new ArgumentOutOfRangeException("direction", direction, null);
     }
     return result;
 }
Пример #4
0
 public Position(Position position)
 {
     Row = position.Row;
     Col = position.Col;
 }