Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Methods Method Overloading

Method Overload

Add a second parameter to the constructor named reactionTime after the existing parameter and use it to initialize the value of the ReactionTime field.

Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {
        public readonly int TongueLength;
        public readonly int ReactionTime;

        public Frog(int tongueLength)
        {
            TongueLength = tongueLength;
        }

        public bool EatFly(int distanceToFly)
        {
            return TongueLength >= distanceToFly;
        }

    }
}

1 Answer

Cam Richardson
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree
Cam Richardson
Front End Web Development Treehouse Moderator 16,895 Points

Hi Winston,

Was there an issue you were experiencing with this code challenge? I'm not exactly sure what you're needing assistance with. In regards to this step in the challenge it is asking that you add another parameter to the constructor for the Frog class. Remember that like methods, constructors can take multiple comma separated parameters, like this:

public class Foo {
    private String Param1;
    private String Param2;    

    public Foo(String param1, String param2) {
        Param1 = param1;
        Param2 = param2;
    }
}

Again, I'm not sure what it is you're needing help with, but I hope this helps.