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()}"); } }
public void Circumference_Sides4_Returns16() { var sut = new Rectangle(0, 4, 0, 4); double result = sut.Circumference(); result.ShouldBe(16.0, 0.0); }
public void Area_Sides4_Returns16() { var sut = new Rectangle(0, 4, 0, 4); double result = sut.Area(); result.ShouldBe(16.0, 0.0); }
public void Area_Sides2x4_Returns8() { var sut = new Rectangle(0, 2, 0, 4); double result = sut.Area(); result.ShouldBe(8.0, 0.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; }
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); }
/** * Determines if a rectangle overlaps in area with this rectangle * */ public bool Overlaps(Rectangle other) { return false; }