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 trialAmit Ghosh
9,314 PointsBummer! Did you create a parameter in your method named distanceToFly?
I am calling the int variable inside the method , compiler says bummer!!
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly( int distanceToFly )
{
bool cond = distanceToFly< Frog.TongueLenght;
return cond;
}
}
}
2 Answers
Jennifer Nordell
Treehouse TeacherHi Amit! There are a couple of things going on here, and one of them is the challenge being picky about the parameter. Even if I fix the other errors, it won't pass without removing the spaces around the parameter. You also have a misspelling in TongueLength
. You've typed TongueLenght
. Note the reversal of the position of the "t" and "h". The "Frog" part is also not needed before this. Take a look:
public bool EatFly (int distanceToFly) // note the removal of the spaces around the parameter
{
bool cond = distanceToFly < TongueLength; // note the removal of Frog and the spelling of "Length"
return cond;
}
I have only included this bit, so you will need to make sure your closed braces are still correct.
Hope this helps!
Amit Ghosh
9,314 PointsThe trailing spaces was interesting. Wouldn't have caught that, was trying to make the code readable and spaced out. Thanks a lot. Also as this method is being called inside Frog class I understand the need not being there, but if its included is it wrong?
Jennifer Nordell
Treehouse TeacherYes, it will be wrong if included. Remember, the TongueLength is available on an instance of the class. Now outside the class on an instance of Frog (lets say Frog myFrog for example), then you'd access that by myFrog.TongueLength
.