Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Methods Methods

Tyler Marquer
Tyler Marquer
5,852 Points

I can't seem to get it to return a bool value..?

My frog cant eat the fly because the tonguelength and distancetofly cant be established but if i add "public" in front it gives me a compiling error

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

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

        public bool EatFly(int distanceToFly)
        {
            if(distanceToFLy <= tongueLength)
            {
               return true;
            }
            else
            {
               return false;
            }
        }

    }
}

1 Answer

Steven Parker
Steven Parker
216,175 Points

The public directive isn't causing a problem, but there are two typos:

  • the if statement has "distanceToFLy" (with capital "L") instead of "distanceToFly"
  • the same line also has "tongueLength" (with lower-case "t") instead of "TongueLength"
Tyler Marquer
Tyler Marquer
5,852 Points

yeah thank you i noticed after i posted this :)