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 trialDominick McCleary
3,012 Pointsi dont know what i am doing wrong
I have the constructor as a public field but every time I hit check work it keeps saying do I have the sideLength parameter. I checked my spelling. What am I doing wrong?
namespace Treehouse.CodeChallenges
{
class Square : Polygon
{
public readonly int SideLength;
public Sqaure(int sideLength) : base(NumSides == 4)
{
SideLength = sideLength;
}
}
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides)
{
NumSides = numSides;
}
}
}
1 Answer
Eduardo Parra San Jose
12,579 PointsHi,
I'll try to help. In the constructor method of the Square class:
public Sqaure(int sideLength) : base(NumSides == 4)
{
SideLength = sideLength;
}
- There is a type error in the constructor method. I guess you wanted to call your constructor method Square (the same as the class) instead of Sqaure.
- What you are passing as argument to the base method is a comparison, not the value 4.
If you fix those two, you' pass the challenge. The code I used was:
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;
}
}
}
I hope it helps. Have a nice day :)