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 trialMakanaka Zindoga
4,860 PointsHello everyone. I'm having problems with task 2 and 3.
Can't run.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
public readonly int ReactionTime;
public readonly int reactionTime;
{
TongueLength = tongueLength;
}
}
}
1 Answer
jb30
44,807 PointsTo have your constructor take two parameters, you can use the form public Frog(int tongueLength, int reactionTime)
, then modify the code inside your constructor to deal with both parameters. You don't need the line
public readonly int reactionTime;
and the lines
{
TongueLength = tongueLength;
}
would need a line such as public Frog(int tongueLength, int reactionTime)
right before it to be the body of a constructor method.