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 trialJared Williams
1,741 PointsThis doesn't make sense
All It says is this: Bummer! If the frog's reaction time and tongue length are the same as the fly's reaction time and its distance, the frog will eat the fly.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public readonly int ReactionTime;
public Frog(int tongueLength, int reactionTime)
{
TongueLength = tongueLength;
ReactionTime = reactionTime;
}
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
public bool EatFly(int FlyReactionTime, int distanceToFly)
{
return EatFly(distanceToFly) && ReactionTime >= FlyReactionTime;
}
}
}
2 Answers
Steven Parker
231,198 PointsThe frog needs to be faster (or equal).
When the frog is faster than the fly, its reaction time will be less than the fly's. So the comparison should be "<=
" instead of ">=
".
Also, it looks like you have the arguments in the wrong order in the method declaration.
Jared Williams
1,741 PointsHey Steven, I was just about to comment I saw the logic error with this. I didn't notice the method declaration. When I was trying to change the logic by making the frog faster it was still complaining. Thanks for the help!