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 trialnave lahav
1,549 Pointswhy is this code not correct? I've done everything the way it should haven't I?
my task is to make a method which takes a parameter called distanceToFly and checks if the frog can reach it
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool Eatfly(distanceToFly){
bool eatfly=distanceToFly<=Frog.TongueLenght;
return(eatfly);
}
}
}
1 Answer
Stuart Wright
41,120 PointsThere are 4 edits here which will make your code pass the challenge:
- The challenge wants the method to be called EatFly, not Eatfly (notice the uppercase F).
- You have a typo inside your method - 'TongueLenght' should be TongueLength.
- You don't need to write Frog.TongueLength inside the method, you can access it using simply TongueLength.
- Your parameter, distanceToFly, needs to have its type declared in the function header (int).
Hope that helps. Let me know if you need any of them explained further.
nave lahav
1,549 Pointsnave lahav
1,549 Pointsgot it, thank you!