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

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,372 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,372 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.