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 trialoss koch
Front End Web Development Techdegree Student 51 Pointsc-objects/methods/method-overloading/Challenge Task 3 of 3
the solution 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 Reaction=ReactionTime >= flyReactionTime;
if(EatFly==true&&Reaction)
{
return true;
}
}
}
}
2 Answers
Steven Parker
231,248 PointsYou're pretty close, I bet you can get it with a few hints:
- if the frogs reaction time is faster, the value would be less than the fly's
- if the frog isn't able to reach the fly in time, the method should return false
- you never need to compare a boolean value with true
- the other form of EatFly takes the distance as a parameter
So for those last 2 items, instead of "EatFly==true
" you might write "EatFly(distanceToFly)
".
oss koch
Front End Web Development Techdegree Student 51 Pointsthank you so much it work