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

Henrik Christensen
Henrik Christensen
Python Web Development Techdegree Student 38,299 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 :-)

Steven Parker
Steven Parker
182,492 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.