Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }