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 trial

C# C# Objects Methods Method Overloading

Charles Harpke
Charles Harpke
33,986 Points

Add 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?

Frog.cs
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
PLUS
Daniel Paradiso
Courses Plus Student 3,915 Points

Shouldn't your constructor take two parameters: int tongueLength and int reactionTime? I don't see anywhere where int reactionTime was initialized.

Daniel Paradiso
Daniel Paradiso
Courses Plus Student 3,915 Points

I tried your challenge with the correction i suspected and it worked, but I couldn't get the next part to work.

andrewgabriel
andrewgabriel
18,106 Points

Your 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
Gareth Welton
2,292 Points

Questions 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.

I 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
Brianna Ingram
642 Points

I am hoping that this question gets rephrased as it makes the brain call the hurt method.

This question should be rephrased. It is worded very poorly.

Yes, this one took the longest. I could not understand the question. They need a glossary as well.