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 trialRoger Sullivan
10,992 Pointsit's throwing no errors and my only clue is "Bummer! try again" so i assume i'm completely off base.
is this not how you initialize the object with a value?
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog (int tongueLength)
{
int TongueLength = tongueLength;
}
Frog frog = new Frog(3);
}
}
1 Answer
Steven Parker
231,198 PointsIt looks like you are creating a new local variable named TongueLength inside the constructor, instead of initializing the property of the same name that you have already defined. That's not an error to the compiler, it just doesn't do what the challenge asked for.
So, instead of this:
int TongueLength = tongueLength;
Just do this:
TongueLength = tongueLength;
And remove this line, it's not part of the challenge:
Frog frog = new Frog(3);
-sp
Roger Sullivan
10,992 PointsRoger Sullivan
10,992 Pointsit will accept the line that you are telling me to change. Third step "Add a constructor to the Frog class that accepts a tongue length parameter value." is what i am trying to achieve? is the line your telling me to remove not meant to do that?
Steven Parker
231,198 PointsSteven Parker
231,198 PointsYou obviously passed task 2 already, perhaps you didn't realize that the "constructor ... that accepts a tongue length parameter value" is this part:
That extra line would create an instance of this class and name it frog. That's certainly not something you would do inside the class itself.
Roger Sullivan
10,992 PointsRoger Sullivan
10,992 Pointsapparently was doing the third step with the second. thank you for your help!