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

Herman Vicens
Herman Vicens
12,540 Points

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){

}

Robert Silva
Robert Silva
6,450 Points
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;
        }
    }
}
Robert Silva
Robert Silva
6,450 Points

Try changing distanceToFly to an int.

Herman Vicens
Herman Vicens
12,540 Points

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

Herman Vicens
Herman Vicens
12,540 Points

It did not worked. I tried that already.

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

Herman Vicens
Herman Vicens
12,540 Points

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