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

Help me with the next step

can someone help guide me through the next step I wrote a method inside the class gave it a parameter and made wrote a bool but I can't figure out what to do next can someone help me?

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

        public Frog(int tongueLength)
        {
            TongueLength = tongueLength;
        }
        public bool EatFly(distanceToFly)
        {

        }
    }
}

1 Answer

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Derrick,

You're getting close. The EatFly method is missing the type of the distanceToFly parameter. The first thing you'll need to do is set the variable type to an int.

public bool EatFly(int distanceToFly)

Within the EatFly method, the challenge wants you to return if the frog can reach the fly based on the tongue length and distance to the fly. This can be accomplish in one line by the condition TongueLength >= distanceToFly.

return TongueLength >= distanceToFly;

I hope this helps.

Happy Coding :)