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 trialSorin Ocneanu
2,767 PointsWhat is wrong ?
What is wrong ?
namespace Treehouse.CodeChallenges
{
class Frog
{
private NumFliesEaten _numFliesEaten;
public GetNumFliesEaten(){
return _numFliesEaten;
}
public void SetNumFliesEaten(NumFliesEaten value){
_numFliesEaten = value;
}
}
}
2 Answers
andren
28,558 PointsYou are treating NumFliesEaten
as if it was a class, it is not. It is just a variable, an int
variable to be specific. Therefore you can't use it as a variable type, your get method also lacks a return type.
If you change the type of the variable to int
and declare a return type for the get method like this:
namespace Treehouse.CodeChallenges
{
class Frog
{
private int _numFliesEaten;
public int GetNumFliesEaten(){
return _numFliesEaten;
}
public void SetNumFliesEaten(int value){
_numFliesEaten = value;
}
}
}
Then your code will pass.
Sorin Ocneanu
2,767 PointsThanks