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

What is wrong here?

I'd tried this in a thousand different ways and I keep getting this: Bummer! Did you create a parameter in your method named distanceToFly?.

The parameter distanceToFly was created. Either the error is misleading or there is something I can't see. Please help!!

Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {

        public readonly int TongueLength;  

        public EatFly(bool distanceToFly)
        {
        }


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


    }
}

6 Answers

Try

public bool EatFly(int distanceToFly){

}

Well, did that work?

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

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

        public bool EatFly(int distanceToFly)
        {
            if(distanceToFly <= TongueLength)
            {
                return true;
            }
            return false;
        }
    }
}

Try changing distanceToFly to an int.

Tried that already. Did not work. The message I get alludes to the missing bool type.

It did not worked. I tried that already.

public bool EatFly(int distanceToFly){ If(distanceToFly< TongueLength){ return true; } else{ return false; } }

Thanks everyone. And thanks to Michael Clark for the best one.