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 trialSadettin Senberber
974 PointsI don't understand what went wrong?
If the frog's reaction time is greater than the fly's reaction time, the frog can't get the fly. This is the warning. I think I'm use true mark that question wants. Please help.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength, int reactionTime)
{
TongueLength = tongueLength;
ReactionTime = reactionTime;
}
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
public readonly int ReactionTime;
public bool EatFly(int distanceToFly, int flyReactionTime)
{
return TongueLength >= distanceToFly;
return ReactionTime <= flyReactionTime;
}
}
}
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! I feel like you're doing pretty well, but you're missing an important aspect here. A method can only ever return one time. Your method has two return statements. Once a return
has been hit, the method will cease execution. You need to combine those two and return the boolean of if the frog's tongue is greater than the distance AND the frog's reaction time is less than the fly's.
Give it another go with this hint in mind, but let me know if you're still stuck!
Sadettin Senberber
974 PointsSadettin Senberber
974 PointsThank you very much it works.