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 trialEslam Elewa
Courses Plus Student 379 PointsWhy i'm still getting a Bummer! Is there a mistake i can't see ?
Why i'm still getting a Bummer! Is there a mistake i can't see ?
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, int flyReactionTime)
{
return TongueLength >= distanceToFly && ReactionTime >= flyReactionTime;
}
}
}
1 Answer
andren
28,558 PointsThere are two issues:
Task 3 asks you to add another method named
EatFly
, it does not ask you to change the existingEatFly
method. Since part of the point of this challenge is to demonstrate method overloading (which is the act of having multiple methods with the same name) changing the existing method kinda defeats the purpose.You check if the frog's reaction time is greater than or equal to the fly's reaction time. You should be checking if it is less than or equal to, since having a lesser reaction time actually means that you react to something faster.
If you fix those two issues like this:
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 distanceToFly, int flyReactionTime)
{
return TongueLength >= distanceToFly && ReactionTime <= flyReactionTime;
}
}
}
Then your code will pass.
Eslam Elewa
Courses Plus Student 379 PointsEslam Elewa
Courses Plus Student 379 PointsFair enough, thanks a lot andren :)