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)
![Daniel Carter](https://secure.gravatar.com/avatar/87d6a7b74e1c20b651f0a6fcf97ccccc?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Daniel Carter
19,991 PointsI'm not sure I'm calling the correct method in the correct class...?
Initially when I tried to submit my answer to the challenge, I got an error message prompting me to call the OnMap method. Tried calling it in MapTests.cs and received a compiler error.
I'm not sure why I have to call the class in the first place. It doesn't look like there were any calls when explained in the video.
namespace TreehouseDefense
{
public class Map
{
public readonly int Width;
public readonly int Height;
public Map(int width, int height)
{
if(width < 1 || height < 1)
{
throw new System.ArgumentOutOfRangeException(
"Map must be at least 1x1");
}
Width = width;
Height = height;
}
public bool OnMap(Point point)
{
return point.X >= 0 && point.X < Width &&
point.Y >= 0 && point.Y < Height;
}
}
}
using Xunit;
namespace TreehouseDefense.Tests
{
public class MapTests
{
[Fact]
public void OnMapTest()
{
int x = 2;
int y = 3;
var point = new Point (x, y);
Assert.Equal(x, point.x);
Assert.Equal(y, point.y);
}
Map.OnMap();
}
}
using System;
namespace TreehouseDefense
{
public class Point
{
public readonly int X;
public readonly int Y;
public Point(int x, int y)
{
X = x;
Y = y;
}
public double DistanceTo(Point point)
{
return Math.Sqrt(Math.Pow(X - point.X, 2.0) + Math.Pow(Y - point.Y, 2.0));
}
}
}