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 trialHerman Vicens
12,540 PointsNeed help. Don't know what is wrong here.
tried doing inner class and also defined after and before and I still get this erros. don't have any compiler error to help either. Any ideas?
namespace Treehouse.CodeChallenges
{
class Polygon
{
class Square : Polygon
{
public readonly int NumSides;
public readonly int SideLength;
public Square (int sideLength) : base (int numSides)
{
NumSides = 4;
SideLength = sideLenght;
}
}
}
}
2 Answers
Steven Parker
231,198 PointsDon't make any changes to the Polygon class.
The new Square class will be defined after the Polygon class.
And when the instructions say "Use base to initialize NumSides to 4.", they mean that literally (so you'd write "base(4)
" after the constructor declaration.
Also, Square doesn't need it's own "NumSides" as it will inherit that from Polygon.
Finally, there's a spelling of "sideLenght" instead of "sideLength".
Herman Vicens
12,540 PointsThanks Steven. You we're right.