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

Bummer: Did you create a parameter in your method named distanceToFly?

I've tried this several ways and the code is written how I understand it works. Could someone please explain to me why this does not work?

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

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

         public bool EatFly(int distanceToFLy)
           {
              bool eatIt = distanceToFly <= TongueLength;

              return eatIt;
           }
    }
}

2 Answers

andren
andren
28,558 Points

You just have a typo in your code.

You have named the parameter distanceToFLy rather than distanceToFly (FLy vs Fly) and since Java (and the code checker in general) is case-sensitive that difference is enough to make your code not work.

If you fix that typo like this:

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

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

         public bool EatFly(int distanceToFly) // distanceToFLy changed to distanceToFly
         {
             bool eatIt = distanceToFly <= TongueLength;
             return eatIt;
         }
    }
}

Then your code will work.

Thank you so much for the fresh eyes, Andren!