public Board(Grid grid) { int numX = BoardLimit.Get().maxX() - BoardLimit.Get().minX() + 1; int numY = BoardLimit.Get().maxY() - BoardLimit.Get().minY() + 1; this.squares = new Square[numX, numY]; for (int i = 0; i < numX; i++) { for (int j = 0; j < numY; j++) { this.squares[i, j] = new Square(i, j); } } this.grid = grid; }
public Square(int xCoordinate, int yCoordinate, Ship shipThere) { if (xCoordinate > BoardLimit.Get().maxX() || xCoordinate < BoardLimit.Get().minX()) { throw new ArgumentException("The xCoordinate parameter (" + xCoordinate + ") must be inclusively between " + BoardLimit.Get().minX() + " and " + BoardLimit.Get().maxX()); } else if (yCoordinate > BoardLimit.Get().maxY() || yCoordinate < BoardLimit.Get().minY()) { throw new ArgumentException("The yCoordinate parameter (" + yCoordinate + ") must be inclusively between " + BoardLimit.Get().minY() + " and " + BoardLimit.Get().maxY()); } else { this.xCoordinate = xCoordinate; this.yCoordinate = yCoordinate; this.hasBeenShot = false; this.shipThere = shipThere; } }
public Square(int xCoordinate, int yCoordinate, Ship shipThere) { if (xCoordinate > BoardLimit.Get().maxX() || xCoordinate < BoardLimit.Get().minX()) { throw new ArgumentException("параметры Х координат (" + xCoordinate + ")должны быть включительно между " + BoardLimit.Get().minX() + " и " + BoardLimit.Get().maxX()); } else if (yCoordinate > BoardLimit.Get().maxY() || yCoordinate < BoardLimit.Get().minY()) { throw new ArgumentException("параметры Y (" + yCoordinate + ")должны быть включительно между " + BoardLimit.Get().minY() + " и " + BoardLimit.Get().maxY()); } else { this.xCoordinate = xCoordinate; this.yCoordinate = yCoordinate; this.hasBeenShot = false; this.shipThere = shipThere; } }