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 trialJonathan Barnthouse
2,801 PointsChallenge Task 1 of 1 Replace the accessor methods with a property named NumFliesEaten with a getter and setter for _nu
please help with "Bummer! Did you replace both accessor methods with a single property?"
I have no error messages when compiling, but need help, what I am I missing? Thanks!
namespace Treehouse.CodeChallenges
{
public class Frog
{
private int _numFliesEaten;
public int GetNumFliesEaten()
{
return _numFliesEaten;
}
public void SetNumFliesEaten(int x)
{
_numFliesEaten = x;
}
}
}
Jonathan Barnthouse
2,801 PointsWhat I am I missing Parker??
namespace Treehouse.CodeChallenges { public class Frog { private int _numFliesEaten;
public int NumFliesEaten
{
get
{
return _numFilesEaten;
}
set
{
_numFliesEaten = value;
}
}
}
2 Answers
Steven Parker
231,198 PointsThat's much better! Now you only have a typo.
You wrote "_numFilesEaten
" instead of "_numFliesEaten
".
Other than that, looking good!
Jonathan Barnthouse
2,801 PointsThank you!
Sara Rena Anderson
15,045 Pointsnamespace Treehouse.CodeChallenges { public class Frog { private int _numFliesEaten;
public int NumFliesEaten
{
get
{
return _numFliesEaten;
}
set
{
_numFliesEaten = value;
}
}
} }
Steven Parker
231,198 PointsSteven Parker
231,198 PointsIt doesn't look like you've changed anything other than the name of the setter argument.
Remember, the object here is to replace both the getter and setter methods with a new property which handles the private field.
You might want to review the Properties video, and watch how the Location property is constructed for the Invader class.