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 Methods

Can someone walk me through this challenge?

I'm stuck on this challenge, I guess i'm not grasping how i'm supposed to accomplish this. Can anyone walk me through it so i can understand what i'm doing wrong?

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

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

        public bool EatFly(DistanceToFly distanceToFly)
        {
            bool lunch = distanceToFly <= TongueLength;

            return lunch;
        }
    }
}

2 Answers

Steven Parker
Steven Parker
229,732 Points

You are really close! The instructions said "It should take a single integer parameter ...", but you declared your parameter as type "DistanceToFly" (which has not been defined).

Once you fix the parameter type, you should pass the challenge.

thank you for you help, so just to be clear, the parameter is in the () of the method [EatFly (distanceToFly)] correct? assuming that is so , I have reworked it and i'm getting the same error. what am i doing wrong?

Steven Parker
Steven Parker
229,732 Points

It looks like the type is missing now, but it needs to be declared as an integer:

        public bool EatFly(DistanceToFly distanceToFly)  // original with wrong type
        public bool EatFly(int distanceToFly)            // fixed

thank you, i finally figured it out

Steven Parker
Steven Parker
229,732 Points

Ramon Sharpe — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!