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 trialSebastian Manczak
3,551 PointsInheritance objective
I'm wondering do I need to create a new class Square and delete the Polygon or add a subclass Square to the existing Polygon? Could I please ask for a couple of hints?
namespace Treehouse.CodeChallenges
{
class Square
{
public readonly int SideLength;
public Square(int 4)
{
Sidelength = sidelength;
}
}
}
1 Answer
Steven Parker
231,269 PointsThe instructions ask you to "Create a new type of polygon called Square." That lets you know that you need to keep Polygon and use it as the base class for Square.
And you'll need to include "sidelength" as the parameter for the constructor. The number 4 will be passed to the "base" constructor to provide the value for "NumSides".