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,405 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!