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 trialleefaragher
Python Development Techdegree Student 18,868 PointsThe Polygon class represents a 2 dimensional shape. It has a public field named NumSides. Create a new type of polygon c
I can't figure what's wrong with this, any ideas?
namespace Treehouse.CodeChallenges
{
public Polygon(int numSides)
{
NumSides = numSides;
}
}
class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength) : base(4)
{
SideLength = sideLength;
}
}
2 Answers
Steven Parker
231,271 PointsRight code, wrong place.
You just need to put your new class inside the namespace. Otherwise, good job!
leefaragher
Python Development Techdegree Student 18,868 PointsThanks Steven, fixed it now by reloading the question, not sure how i managed to delete it!
leefaragher
Python Development Techdegree Student 18,868 Pointsleefaragher
Python Development Techdegree Student 18,868 PointsHi Steven, I moved the curly brace from just after the code block contained in numSides to the end of the code to include in the namespace but it's still incorrect, it says: "have you deleted the polygon class?"
Steven Parker
231,271 PointsSteven Parker
231,271 PointsSure enough, it looks like part of the original code got deleted. The code above is missing both the definition of the Polygon class and the declaration of the NumSides property. When I open the challenge fresh it has those code lines.
Be sure to add your new class without removing any of the original code.