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 trialTyler Marquer
12,859 PointsI can't seem to get it to return a bool value..?
My frog cant eat the fly because the tonguelength and distancetofly cant be established but if i add "public" in front it gives me a compiling error
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public readonly int DistanceToFly;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceToFly)
{
if(distanceToFLy <= tongueLength)
{
return true;
}
else
{
return false;
}
}
}
}
1 Answer
Steven Parker
231,198 PointsThe public
directive isn't causing a problem, but there are two typos:
- the
if
statement has "distanceToFLy" (with capital "L") instead of "distanceToFly" - the same line also has "tongueLength" (with lower-case "t") instead of "TongueLength"
Tyler Marquer
12,859 PointsTyler Marquer
12,859 Pointsyeah thank you i noticed after i posted this :)