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 trialKhumoyunmirzo Nosirov
8,689 PointsWrite a method inside the Frog class named EatFly. It should take a single integer parameter named distanceToFly and ret
can Anyone help me please
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
bool reach = distanceToFly >= tongueLength;
return reach;
}
}
}
3 Answers
Steven Parker
231,248 PointsHere's a few hints:
- don't make any changes to the "Frog" constructor, add your new method after it.
- your new methods name should be "EatFly"
- your method should take a parameter named "distanceToFly"
- your code to test the distance should use the "TongueLength" field (with capital "T")
Give it another try with these in mind and I'll bet you get it. If not, write again with your revised code.
Khumoyunmirzo Nosirov
8,689 Pointsnamespace Treehouse.CodeChallenges { class Frog { public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceFly)
{
bool reachSky = distanceFly >= TongueLength;
}
}
}
Khumoyunmirzo Nosirov
8,689 PointsI am trying , but it is not working !
Steven Parker
231,248 PointsClose, but this time you forgot to return the result.
Khumoyunmirzo Nosirov
8,689 Pointsnamespace Treehouse.CodeChallenges { class Frog { public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceToFly)
{
bool reachSky = distanceToFly >= TongueLength;
return reachSky;
}
}
}
what about this time;
Steven Parker
231,248 PointsThe function should return a true value when the tongue is longer or equal to the distance.
Also, the challenge can be a bit picky about formatting. You might need to remove the extra space between "public" and "bool".