コード例 #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;
        }
コード例 #2
0
ファイル: Square.cs プロジェクト: Jean-Claude-D/BattleShip
 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;
     }
 }
コード例 #3
0
ファイル: Square.cs プロジェクト: hetag34/ship34
 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;
     }
 }