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 trialLuis Santos
3,566 PointsI am stuck on this part, thought I had the problem worked out but apparently I don't. Any help will be appreciated.
I understood the challenge perfectly and felt I could do it with no problem. However, I got stuck according to the code challenge engine. I've looked at C# documentation and other posts concerning this particular problem. I have yet to find an adequate solution as to why my method of doing this problem is not working.
namespace Treehouse.CodeChallenges
{
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides)
{
NumSides = numSides;
public class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength) : base (4)
{
SideLength = sideLength;
}
}
}
2 Answers
Cindy Lea
Courses Plus Student 6,497 PointsIt looks right but wont pass challenge. I used my code & it passes but dont have time to really look at why right now. Heres what worked for me:
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;
}
}
}
Steven Parker
231,198 PointsIt looks like you placed your new class inside the constructor for "Polygon".
Move your class definition below the class definition for "Polygon".
You may also need to remove the "public" before "class". It didn't seem right, but I found it necessary to pass the challenge. You may want to report this as a bug to Treehouse Support.