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 trialDavid Alberto Mogollon
Full Stack JavaScript Techdegree Student 13,759 PointsI dont know what is wrong with my code:
I verified everything and still dont know what is wrong . help please
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)
{
bool distanceOk = EatFly(distanceToFly);
bool reactionOk = ReactionTime >= flyReactionTime;
System.Console.WriteLine("distance : " +distanceOk);
System.Console.WriteLine("reaction : " +reactionOk);
if( distanceOk && reactionOk ){ System.Console.WriteLine(" pass"); return true;}
else{System.Console.WriteLine(" fail"); return false;}
}
}
}
1 Answer
Roman Fincher
18,267 PointsYou should be getting the error: Bummer! If the frog's reaction time is greater than the fly's reaction time, the frog can't get the fly (I did when I ran your code).
In other words, change:
bool reactionOk = ReactionTime >= flyReactionTime;
to
bool reactionOk = ReactionTime <= flyReactionTime;