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 trialJUAN CARLOS ESTUDILLO
271 PointsIΒ΄m stock !! it send me the following message "Bummer! Did you create a parameter in your method named distanceToFly?"
Can I have a copy of the code.? to find out my mistake, please.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public readonly int DistanceToFly;
public Frog( int tongueLength )
{
TongueLength = tongueLength;
DistanceToFly = distanceToFly;
public bool EatFly ( int distanceToFly )
{
bool TongueLenght = DistanceToFly
return TongueLenght;
}
}
}
}
2 Answers
Steven Parker
231,198 PointsIt looks like you still need to work on the body of the method a bit, but the main issue is that the method is currently inside the constructor. Both the constructor and the new method should be inside the class, but peers to each other.
JUAN CARLOS ESTUDILLO
271 PointsIΒ΄m so sorry, help me. Please
My code, ItΒ΄s no working :(:
namespace Treehouse.CodeChallenges { class Frog { public readonly int TongueLength; public readonly int DistanceToFly;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
DistanceToFly = distanceToFly;
}
public bool EatFly ( int distanceToFly )
{
bool FlyReach = Frog.TongueLength == Frog.DistanceToFly
return true;
bool FlyNotReach = Frog.TongueLength != Frog.DistanceToFly
return false;
}
}
}
Steven Parker
231,198 PointsHere's a few more hints:
- don't modify the supplied code for the constructor
- the instructions do not ask for a new readonly variable
- remember to end statements with semicolons
- making a bool is optional, but if you do make one you probably want to use it as the return value
- be sure to use comparisons that test for equal and greater
- avoid extra spaces around parentheses β it's OK in practice but the challenge is picky about it
JUAN CARLOS ESTUDILLO
271 PointsIt is almost done. Thank you.
JUAN CARLOS ESTUDILLO
271 PointsJUAN CARLOS ESTUDILLO
271 Pointsnamespace Treehouse.CodeChallenges { class Frog { public readonly int TongueLength; public readonly int DistanceToFly;
}