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 trialCharles Harpke
33,986 PointsAdd a second parameter to the constructor named reactionTime after the existing parameter and use it to initialize...
I added the reaction time parameter:
namespace Treehouse.CodeChallenges { class Frog { public readonly int TongueLength; public readonly int ReactionTime; public Frog(int tongueLength) { TongueLength = tongueLength; ReactionTime = reactionTime; }
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
}
}
Bummer! Did you add a reactionTime parameter to the Frog constructor after the tongueLength parameter?
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public readonly int ReactionTime;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
ReactionTime = reactionTime;
}
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
}
}
6 Answers
Daniel Paradiso
Courses Plus Student 3,915 PointsShouldn't your constructor take two parameters: int tongueLength and int reactionTime? I don't see anywhere where int reactionTime was initialized.
andrewgabriel
18,106 PointsYour code is correct however you forgot to pass in reactionTime as a second parameter in addition to toungeLength. Here is how I wrote it and it worked. I think the instructions could be a little bit more clear because I got confused as well.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public readonly int ReactionTime;
public Frog(int tongueLength, int reactionTime)
{
TongueLength = tongueLength;
ReactionTime = reactionTime;
}
public bool EatFly(int distanceToFly)
{
return TongueLength >= distanceToFly;
}
}
}
Gareth Welton
2,292 PointsQuestions should be phrased:
Add a second parameter named reactionTime after the existing parameter to the constructor and use it to initialize...
I also was confused but then I have a small brain.
Mohammad Hanbali
13,325 PointsI was also confused by this. When read aloud the sentence makes it sound as if the constructor itself is named reactionTime. It would've been less confusing if it read: Add a second parameter to the constructor, name it reactionTime...
Brianna Ingram
642 PointsI am hoping that this question gets rephrased as it makes the brain call the hurt method.
JARROD PEOPLES
1,347 PointsThis question should be rephrased. It is worded very poorly.
Cinitae Savage
1,157 PointsYes, this one took the longest. I could not understand the question. They need a glossary as well.
Daniel Paradiso
Courses Plus Student 3,915 PointsDaniel Paradiso
Courses Plus Student 3,915 PointsI tried your challenge with the correction i suspected and it worked, but I couldn't get the next part to work.