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

Butler Fuqua
Butler Fuqua
210 Points

I get the question "Did you create a parameter in your method named distanceToFly?" I did, so I don' know the mistake.

My code complies and I don't understand the question that I am prompted with, so I do not know how to see my mistake.

Thank you for any response!

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

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


        public bool EatFly  (Frog distanceToFly)
        {
            bool inBounds = distanceToFly <= TongueLength;
            return inBounds;
        }
    }
}

2 Answers

andren
andren
28,558 Points

The problem is that in your method declaration you mark the distanceToFly parameter as a Frog object, the challenge asked you to create a method that took an int called distanceToFly.

Change Frog to int in your method declaration and your code should pass.

Butler Fuqua
Butler Fuqua
210 Points

Thank you Andren, that worked! God bless