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

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.