public void IsCoordinateInsideTest() { Coordinate landingRequest = new Coordinate(5, 5); SquareArea sa = AreasService.CreateSafetyArea(landingRequest); Assert.IsTrue(AreasService.IsCoordinateInside(sa, new Coordinate(4, 4))); Assert.IsFalse(AreasService.IsCoordinateInside(sa, new Coordinate(11, 11))); }
/// <summary> /// Method to control the requests of landing from the rockets /// </summary> /// <param name="rocketLandingPosition">x,y pair to check</param> /// <returns type=string>ok for landing - when there is no problem to land /// out of the platform - request is outside of landing platform /// clash - the previous rocket check for the same position or the /// checked position is within the safety area of the previous /// rocket ///</returns> public string LandingRequest(Coordinate rocketLandingPosition) { string response = string.Empty; if (PreviousRocketLandingPosition != null && AreasService.IsCoordinateInside(PreviousRocketLandingPosition, rocketLandingPosition)) { response = Response.CLASH; } else if (AreasService.IsCoordinateInside(LandingPlatform, rocketLandingPosition)) { response = Response.OK_FOR_LANDING; } else { response = Response.OUT_OF_PLATFORM; } // we save the request of landing PreviousRocketLandingPosition = AreasService.CreateSafetyArea(rocketLandingPosition); return(response); }