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#

I can't pass the Method Overloading 3rd task.

Hi I created the exactly what they asked but its not letting me go further. Please help.

Task URL : https://teamtreehouse.com/library/c-objects/methods/method-overloading

Task Description

Add another method named EatFly that takes two integer parameters and returns a boolean value. Name the parameters distanceToFly and flyReactionTime. Return true if the frog’s tongue is longer or equal to than the distance to the fly and its reaction time is faster or equal to than the fly’s reaction time.

Bummer

Bummer! Did you create a new EatFly method that takes two integer parameters named distanceToFly and flyReactionTime?

My code

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;

    }
    public bool EatFly(int distanceToFly,int flyReactionTime)
    {
        return TongueLength >= distanceToFly && 
               ReactionTime >= flyReactionTime;
    }
}

}

Thanks!

1 Answer

Steven Parker
Steven Parker
231,236 Points

:point_right: The challenge has at least one peculiar syntax requirement.

While it's perfectly legal in C# to space or not, the challenge apparently requires a space between the comma and second argument in the method definition. You may want to report this as a bug on the Support page.

You'll also find that to catch the fly, the frog's reaction time must be less than or equal to the fly's.

Thanks Steven