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 trialabdur rafay
1,933 PointsI dont understand why this is not correct.
I have done everything the question stated, I also tried to use preview but it does not seem to show any errors.
namespace Treehouse.CodeChallenges
{
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides)
{
NumSides = numSides;
}
}
class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength) : base (numSides)
{
SideLength = sideLength;
numSides = 4;
}
}
1 Answer
calp
10,317 PointsHello, I have identified the following with the code that you supplied, you are missing the closing brace for your Square class, and you are not passing 4 into the base constructor.
Here is the code with the two simple fixes,
namespace Treehouse.CodeChallenges
{
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides)
{
NumSides = numSides;
}
}
class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength) : base(4)
{
SideLength = sideLength;
}
}
}
As you can see, you were definitely on the right track!
abdur rafay
1,933 Pointsabdur rafay
1,933 PointsOh thank-you so much, such a simple mistake on my part.