C# C# Objects Methods Methods

How to use bool

Write a method inside the Frog class named EatFly. It should take a single integer parameter named distanceToFly and return a bool value. It should return true if the frog can reach the fly with its tongue, and false otherwise

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

        public Frog(int tongueLength)
        {
            TongueLength = tongueLength;
        }
     public bool EatFly(DistanceToFly distanceToFly) 
     { 
         bool reach = distanceToFly<=tongueLength;
         return reach;
     }
    }

}

1 Answer

Steven Parker
Steven Parker
182,603 Points

The instructions say your function "should take a single integer parameter named distanceToFly", but instead of an int, your parameter type is "DistanceToFly" (which is not defined).

Also, in your comparison, you wrote "tongueLength" (with a lower-case "t") instead of "TongueLength" (capital "T").