Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Michael North](https://secure.gravatar.com/avatar/5d3ceea3ef47d4231ce770cf32ef9f98?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Michael North
2,561 PointsNo over load for method DistanceTo
namespace TreehouseDefense { class MapLocation : Point { public MapLocation(int x, int y, Map map) : base(x, y) { if (!map.OnMap(this)) { throw new OutOfBoundsException(x + ", " + y + " is outside the boundries of the map."); } }
public bool InRangeOf(MapLocation location, int range)
{
return DistanceTo(location) <= range;
}
}
}
! followed everything in the video and this problem came up can someone please tell me whats wrong?
![Michael North](https://secure.gravatar.com/avatar/5d3ceea3ef47d4231ce770cf32ef9f98?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Michael North
2,561 Points![Michael North](https://secure.gravatar.com/avatar/5d3ceea3ef47d4231ce770cf32ef9f98?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Michael North
2,561 PointsThank you very much, Steven. It means a lot that people are out there to help me learn :).
2 Answers
![Timothy Schmidt](https://secure.gravatar.com/avatar/68541ed01db9221310eafb7baf4c4a63?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Timothy Schmidt
4,806 PointsIn the vidoes, the only DistanceTo
method in the Point
class requires both an X and a Y to be passed to it.
return DistanceTo(Location.X, Location.Y) <= range;
The code you have was a mistake in the videos. He never shows it during the series, but if you download the project files, you'll find that they include a second function in the Point
class that looks like this:
public int DistanceTo(Point point)
{
return DistanceTo(point.X, point.Y);
}
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe error message seems to be correct.
In the current workspace program, there is no overload for DistanceTo that would take a single Location object argument. But I know the program evolves during the course, so perhaps you're at an intermediate stage right before one is to be made.
But for right now, you could substitute this line to call with the current requirements (Timothy was close, except for the name "location"):
return DistanceTo(location.X, location.Y) <= range;
Steven Parker
230,688 PointsSteven Parker
230,688 PointsTo enable a complete and accurate analysis, make a snapshot of your workspace and post the link to it here. Also please provide a link the the course page you are working with.