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 trialNicolas Bastos
4,209 PointsI am getting an error when compiling the code.
This is the code that I have: namespace TreehouseDefense { class Path {
private readonly MapLocation[] _path;
public Path(MapLocaiton[] path)
{
_path = path;
}
public MapLocation GetLocationAt(int pathStep)
{
return (pathStep < _path.Length) ? _path[pathStep] : null;
}
}
}
And the error that I get is this: Path.cs(8,20): error CS0246: The type or namespace name 'MapLocation' could not be found. Are you missing an assembly reference?
This is the code from MapLocation.cs: 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 bondaries of the map");
}
}
}
}
1 Answer
Steven Parker
231,236 PointsYour build command may be incomplete.
It looks like the MapLocation.cs might not have been included in the build. Did you build using this command?
mcs *.cs -out:TreehouseDefense.exe
Nicolas Bastos
4,209 PointsNicolas Bastos
4,209 PointsYeah, I keep getting the same error, i dont know what to do.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsTo allow for a more complete analysis, please make a snapshot of your workspace and provide the link to it.
Nicolas Bastos
4,209 PointsNicolas Bastos
4,209 PointsHere is the snapshot:
https://w.trhou.se/kxz6j1wfix
Steven Parker
231,236 PointsSteven Parker
231,236 PointsCheck the spelling of "MapLocation".
On line 8 of Path.cs you have "MapLocaiton" but it should be "MapLocation".
Nicolas Bastos
4,209 PointsNicolas Bastos
4,209 PointsThank you!