C# C# Objects Inheritance Inheritance

Sebastian Manczak
Sebastian Manczak
3,551 Points

Inheritance 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?

Polygon.cs
namespace Treehouse.CodeChallenges
{
    class Square
    {
        public readonly int SideLength;

        public Square(int 4)
        {
            Sidelength = sidelength;
        }
    }
}

1 Answer

Steven Parker
Steven Parker
177,509 Points

The 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".