Exemplo n.º 1
0
        private static bool Adjacent(int currentCellNum, int otherCellNum)
        {
            if (currentCellNum - 1 == otherCellNum)
            {
                return(true);
            }
            if (otherCellNum == 1 && currentCellNum <= 9)
            {
                return(true);
            }

            Rank currentRank = new Rank(RankNum(currentCellNum));
            Rank otherRank   = new Rank(RankNum(otherCellNum));

            if (currentRank.rank != otherRank.rank &&
                currentRank.rank - 1 != otherRank.rank)
            {
                throw new Exception("cell number must be in the current or prior rank to be adjacent");
            }

            Coordinate currCoord  = currentRank.GetCoordinate(currentCellNum);
            Coordinate otherCoord = otherRank.GetCoordinate(otherCellNum);

            return(Coordinate.AreNeighbors(currCoord, otherCoord));
        }