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 trialhavocblast
604 PointsI am not sure why the challenge says my code is wrong.
I am unsure why the challenge is saying I failed.
The challenge wants me to return true if the fly is in reach of the mouth. the distanceToFly - TongueLength should equal 0 to make the statement true.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceToFly)
{
if(distanceToFly - TongueLength == 0)
{
return true;
}
else
{
return false;
}
}
}
}
2 Answers
KRIS NIKOLAISEN
54,971 PointsThe mysterious down vote. It would help me (and maybe others) understand when this is done if there was an explanation as to why.
If you are 2 feet away and my arm is 2 feet long I can reach you.
If you are 2 feet away and my arm is 3 feet long I can still reach you.
KRIS NIKOLAISEN
54,971 PointsHint: Wouldn't the fly also be eaten if TongueLength was greater than distanceToFly? You are only considering if they are the same length.