コード例 #1
0
        public bool ContainsSquare(string square)
        {
            shipRowStart    = Convert.ToInt32(TopLeft.First().ToString());
            shipRowEnd      = Convert.ToInt32(BottomRight.First().ToString());
            shipColumnStart = (TopLeft.Skip(1).First() - 'A') + 1;
            shipColumnEnd   = (BottomRight.Skip(1).First() - 'A') + 1;

            int squareRow    = Convert.ToInt32(square.First().ToString());
            int squareColumn = (square.Skip(1).First() - 'A') + 1;

            if (squareRow >= shipRowStart && squareRow <= shipRowEnd && squareColumn >= shipColumnStart && squareColumn <= shipColumnEnd)
            {
                return(true);
            }

            return(false);
        }