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 trialJorge Kalil
1,832 PointsThis code shows no compile error but it keeps stating: Did you create a parameter in your method named distanceToFly?
Might you know why?
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tonguelength;
}
public bool EatFly( int distanceToFly )
{
bool canReach = tonguelength <= distancetofly;
return canReach;
}
}
}
1 Answer
Steven Parker
231,198 PointsThe message is a bit misleading.
Apparently, the pre-compiler syntax checker doesn't like the spaces inside the parentheses around your argument. This restriction has nothing to do with acceptable syntax for the compiler. You might even want to report it as a bug.
However, you also have a few issues in the code:
- inside your method, you spelled "distancetofly" (all lower case) instead of "distanceToFly"
- you also wrote "tonguelength" instead of "TongueLength"
- and you check if the tongue is less than or equal to the distance, instead of greater than or equal
Dirk Walzel
5,431 PointsDirk Walzel
5,431 PointsChange the following
a.) in EatFly you type distancetofly. Correct would be distanceToFly b.) you check vs tonguelenght not TongueLength c.) the distanceToFly should be smaller or equal then the TongueLength (dTF<=TL)
And you actually don't need a variable canReach
Plus you messed up the code in Frog should be TongueLength = tongueLength;
Following code should work
public bool EatFly(int distanceToFly) { return distanceToFly<=TongueLength; }