C# C# Objects Methods Methods

I´m stock !! it send me the following message "Bummer! Did you create a parameter in your method named distanceToFly?"

Can I have a copy of the code.? to find out my mistake, please.

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

        public Frog( int tongueLength )
        {
            TongueLength = tongueLength;
            DistanceToFly = distanceToFly;

            public bool EatFly ( int distanceToFly )
            {
                bool TongueLenght = DistanceToFly 
                return TongueLenght;
            }            
        }
    }
}

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

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

    public bool EatFly ( int DistanceToFly )
        {
           if ( bool TongueLength = DistanceToFly )
                return true;
           else
                return false;
        }  
}

}

2 Answers

Steven Parker
Steven Parker
187,287 Points

It looks like you still need to work on the body of the method a bit, but the main issue is that the method is currently inside the constructor. Both the constructor and the new method should be inside the class, but peers to each other.

I´m so sorry, help me. Please

My code, It´s no working :(:

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

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

    public bool EatFly ( int distanceToFly )
        {
           bool FlyReach = Frog.TongueLength == Frog.DistanceToFly
                return true;

           bool FlyNotReach = Frog.TongueLength != Frog.DistanceToFly
                return false;
        } 
}

}

Steven Parker
Steven Parker
187,287 Points

Here's a few more hints:

  • don't modify the supplied code for the constructor
  • the instructions do not ask for a new readonly variable
  • remember to end statements with semicolons
  • making a bool is optional, but if you do make one you probably want to use it as the return value
  • be sure to use comparisons that test for equal and greater
  • avoid extra spaces around parentheses — it's OK in practice but the challenge is picky about it

It is almost done. Thank you.