//Сравнение верхней стены с нижней
 bool compareWallTB(
     Wall wallN1,
     Wall wallN2)
 {
     if (wallN1.YLeftTop ==
         wallN2.YLeftTop)
     {
         if (
                 ((wallN1.XRightBottom <=
                 wallN2.XLeftTop)
                 &&
                 (wallN1.XLeftTop <=
                 wallN2.XRightBottom))
                 ||
                 ((wallN2.XRightBottom <=
                 wallN1.XLeftTop)
                 &&
                 (wallN2.XLeftTop <=
                 wallN1.XRightBottom))
             )
             return false;
         else return true;
     }
     return false;
 }
        //Поиск общей стены. Если общая стена существует,
        //результат true, иначе false.
        bool CheckTheWall(
            Room roomN1,
            Room roomN2
            )
        {
            if (!roomN1.IsUsed)
                return true;
            else
            {
                #region Wall
                Wall wcLeftWallR1 = new Wall(
                    roomN1.xCoordinate,
                    roomN1.yCoordinate,
                    roomN1.xCoordinate,
                    roomN1.yCoordinate + roomN1.RoomLength
                    );
                Wall wcRigthWallR1 = new Wall(
                    roomN1.xCoordinate + roomN1.RoomWidth,
                    roomN1.yCoordinate,
                    roomN1.xCoordinate + roomN1.RoomWidth,
                    roomN1.yCoordinate + roomN1.RoomLength
                    );
                Wall wcTopWallR1 = new Wall(
                    roomN1.xCoordinate,
                    roomN1.yCoordinate,
                    roomN1.xCoordinate + roomN1.RoomWidth,
                    roomN1.yCoordinate
                    );
                Wall wcBottomWallR1 = new Wall(
                    roomN1.xCoordinate,
                    roomN1.yCoordinate + roomN1.RoomLength,
                    roomN1.xCoordinate + roomN1.RoomWidth,
                    roomN1.yCoordinate + roomN1.RoomLength
                    );

                Wall wcBottomWallR2 = new Wall(
                    roomN2.xCoordinate,
                    roomN2.yCoordinate,
                    roomN2.xCoordinate,
                    roomN2.yCoordinate + roomN2.RoomLength
                    );
                Wall wcRigthWallR2 = new Wall(
                    roomN2.xCoordinate + roomN2.RoomWidth,
                    roomN2.yCoordinate,
                    roomN2.xCoordinate + roomN2.RoomWidth,
                    roomN2.yCoordinate + roomN2.RoomLength
                    );
                Wall wcTopWallR2 = new Wall(
                    roomN2.xCoordinate,
                    roomN2.yCoordinate,
                    roomN2.xCoordinate + roomN2.RoomWidth,
                    roomN2.yCoordinate
                    );
                Wall wcBottomWallR2 = new Wall(
                    roomN2.xCoordinate,
                    roomN2.yCoordinate + roomN2.RoomLength,
                    roomN2.xCoordinate + roomN2.RoomWidth,
                    roomN2.yCoordinate + roomN2.RoomLength
                    );
                #endregion

                return (compareWallLR(wcLeftWallR1, wcRigthWallR2) ||
                    compareWallLR(wcBottomWallR2, wcRigthWallR1) ||
                    compareWallTB(wcTopWallR2, wcBottomWallR1) ||
                    compareWallTB(wcTopWallR1, wcBottomWallR2));
            }
        }
 bool compareWallLR(
     Wall wallN1,
     Wall wallN2)
 {
     if ((wallN1.XLeftTop) ==
         (wallN2.XLeftTop))
     {
         if (
                 ((wallN1.dbl_y2_coordinate <=
                 wallN2.YLeftTop)
                 &&
                 (wallN1.YLeftTop <=
                 wallN2.dbl_y2_coordinate))
                 ||
                 ((wallN2.dbl_y2_coordinate <=
                 wallN1.YLeftTop)
                 &&
                 (wallN2.YLeftTop <=
                 wallN1.dbl_y2_coordinate))
             )
             return false;
         else return true;
     }
     return false;
 }