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

Xavier Swehla
Xavier Swehla
2,852 Points

I do not understand the question for the code challenge.

I do not know what else to add/edit especially since I am not receiving a compiling error. I do not understand what they mean when the error reads "Bummer! did you create parameters for distanceToFly?" Any thoughts?? Any answer is appreciated.

Code Challenge Question: 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)
        {
            bool distanceToFly = tonguelength.TongueLength > distanceToFly
        }
    }
}

2 Answers

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Yup forgot it, i didnt' even look at the challenge, you need to type the parameter, so int distanceToFly :

        public bool EatFly(int distanceToFly)
        {
            return TongueLength >= distanceToFly; // true if the tongueLength is greater than or equal to distanceToFly
        }
Xavier Swehla
Xavier Swehla
2,852 Points

ok thanks, I think i should be able to iron out the compiling errors from here. Thanks

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

In the method EatFly you need to return the value of the comparison

        public bool EatFly(distanceToFly)
        {
            return tonguelength.TongueLength >= distanceToFly; // true if the tongueLength is greater than or equal to distanceToFly
        }
Xavier Swehla
Xavier Swehla
2,852 Points

" Bummer! Did you create a parameter in your method named distanceToFly?" is the message that I receive. Idk what that is supposed to mean.