Example #1
0
        static void Main(string[] args)
        {
            var inputParameters =
                Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(int.Parse)
                    .ToArray();

            var rectangles = new Dictionary<string, Rectangle>();

            var numberOfRectangles = inputParameters[0];
            for (int i = 0; i < numberOfRectangles; i++)
            {
                var rectangleParameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var id = rectangleParameters[0];
                var width = float.Parse(rectangleParameters[1]);
                var height = float.Parse(rectangleParameters[2]);
                var x = float.Parse(rectangleParameters[3]);
                var y = float.Parse(rectangleParameters[4]);

                rectangles[id] = new Rectangle(width, height, x, y);
            }

            var numberOfChecks = inputParameters[1];
            for (int i = 0; i < numberOfChecks; i++)
            {
                var checkParameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var firstRectangle = rectangles[checkParameters[0]];
                var secondRectangle = rectangles[checkParameters[1]];

                Console.WriteLine($"{firstRectangle.Intersects(secondRectangle).ToString().ToLower()}");
            }
        }
Example #2
0
        public void Circumference_Sides4_Returns16()
        {
            var sut = new Rectangle(0, 4, 0, 4);

            double result = sut.Circumference();

            result.ShouldBe(16.0, 0.0);
        }
Example #3
0
        public void Area_Sides4_Returns16()
        {
            var sut = new Rectangle(0, 4, 0, 4);

            double result = sut.Area();

            result.ShouldBe(16.0, 0.0);
        }
Example #4
0
        public void Area_Sides2x4_Returns8()
        {
            var sut = new Rectangle(0, 2, 0, 4);

            double result = sut.Area();

            result.ShouldBe(8.0, 0.0);
        }
Example #5
0
        public bool OverlapsWith(Rectangle overlappingRectangle)
        {
            if (overlappingRectangle._xMax < _xMin)
                return false;

            if (overlappingRectangle._xMin > _xMax)
                return false;

            if (overlappingRectangle._yMax < _yMin)
                return false;

            if (overlappingRectangle._yMin > _yMax)
                return false;

            return true;
        }
Example #6
0
        public void Overlaps_OverlappingRectangles_ReturnsTrue()
        {
            var sut = new Rectangle(0, 2, 0, 4);
            var overlappingRectangle = new Rectangle(0, 4, 0, 4);

            bool result = sut.OverlapsWith(overlappingRectangle);

            result.ShouldBe(true);
        }
Example #7
0
 /**
  * Determines if a rectangle overlaps in area with this rectangle
  * */
 public bool Overlaps(Rectangle other)
 {
     return false;
 }