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

Louis Colbert
Louis Colbert
709 Points

HA!!!! I have no clue! not sure what I am missing here. but I understand its very basic.

very confused as to this question. or the related output. possibly just me not knowing where to go from here or how to code this.

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

        public bool EatFly(int distanceToFly)
        {
           if(distanceToFly >10)
           {
               bool eatfly;
               EatFly = eatfly

           }

        }

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

2 Answers

Steven Parker
Steven Parker
231,248 Points

You've got the right idea about testing "distanceToFly" in an "if" statement, but you will want to compare it with the "TongueLength". If the distance is more than the tongue's length, then you can simply "return false" to indicate it won't be eaten. Otherwise, "return true" to indicate that it can.

You won't need to create any new variables in this step.

If you're still stuck, you might also want to take a look at some of the other questions and answers on the forum about this same challenge.

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

The method name and parameter seems okay, but you're asked to do the following:

if the distanceToFly is greater than the the tongueLength of the Frog, then you should return false - otherwise return true

I hope this is helpful :-)