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 Encapsulation with Properties Accessor Methods

Ok, so i'm doing this test and I can't figure out what i'm supposed to pass through this SetFliesEaten setter method.

There's little to no information in the video about setting up this getter and setter method. in the video, it was calling from another method called MapLocation, we don't have that here. So what am I supposed to attach _numFliesEaten to in the setter method?

Frog.cs
namespace Treehouse.CodeChallenges
{
    class Frog
    {
        private int _numFliesEaten;

        public int GetNumFliesEaten()
        {
            return _numFliesEaten;
        }

        public void int SetNumFliesEaten(????)
        {
           _numFliesEaten = ????
        }

    }
}

1 Answer

Hi Joseph,

You're close. Since the setter is void, you don't declare a return type "int." But, you do pass an int variable into the setter. So, replace your ???? with something like "int numFlies" in the method declaration and ???? in the body to numFlies. The challenge doesn't care what the actual parameter name you choose to use, it just checks type and consistency of use in the code.

Hope this helps.