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

C# C# Objects Methods Return Values

Denzel Archie
Denzel Archie
8,421 Points

Compiler/Unexpected symbol

I'm having trouble identifying where the unexpected is. it says line 14, but on my workspace that line is actually just white space.

      Point point = new Point(4, 2);
       bool isOnMap = map.OnMap(point);
       Console.WriteLine(isOnMap);

       point = new Point(8, 5);
       isOnMap = map.OnMap(point);
       Console.WriteLine(isOnMap);
Steven Parker
Steven Parker
229,744 Points

It might be necessary to see more of the code to analyze the issue. You can share the entire project at once if you make a snapshot of your workspace and post the link to it here.

1 Answer

Steven Parker
Steven Parker
229,744 Points

When I open the workspace, line 14 of Map.cs is:

    public bool OnMap(Point, point)

There's a stray comma there between the parameter type and the name. Also in the same method:

  • the fields inside point are "X" and "Y" (upper case) but the code has them in lower case
  • the local field "Width" (capital "W") is spelled in the code as "width" (lower case "w")
  • the local field "Height" (capital "H") is spelled in the code as "height" (lower case "h")
Denzel Archie
Denzel Archie
8,421 Points

Oh I was looking for the error in the Game file, but should've noticed it was in Maps'. Thank You