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

Derian McCrea
Derian McCrea
1,370 Points

Bummer! Did you create a parameter in your method named distanceToFly? Help please.

I'm not sure if i'm understanding the method parameter I've used.

Is (int Point point) not a viable parameter for the method to measure distance?

If it's not, how does the code execute past it, to give me an error stating I haven't created bool parameter "distanceToFly".

I'm wondering if I need to clarify my understanding of what needs to be declared for the method parameter.

I've checked out the other answers, and my code doesn't look the same. I feel like there is something logically i'm not registering.

Thanks for any clarification!

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

        public Frog(int tongueLength)
        {
            TongueLength = tongueLength;

        }

        public bool EatFly ( int Point point)   
        {
                bool distanceToFly = point.X >=0 && point.X < TongueLength;

                return distanceToFly;

        }
    }
}

1 Answer

Stuart Wright
Stuart Wright
41,120 Points

The correct solution is simpler than what you are attempting to do. Here are some hints:

  • the parameter which you pass in should be of type int (not Point).
  • the parameter you pass in should be called distanceToFly (not point).
  • bool is the return type, not the parameter type.
  • you need to return true or false depending on whether or not the integer distanceToFly is less than or equal to TongueLength.

What is the exact error message that you are receiving? It shouldn't be saying anything about a bool parameter, as that is not needed for this challenge.

Derian McCrea
Derian McCrea
1,370 Points

Thanks for the feedback.

To answer your question, the error message i'm receiving is the same error i posted as the title. "Bummer! Did you create a parameter in your method named distanceToFly?" When I switch it to the preview (eye) button I see no red code compile message errors. It's just blank with the same error message as above that shakes.

I'll try to simplify my approach and review the video portion associated with this lesson. This is all new to me.