Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Inheritance Inheritance

i think i did everything correctly but it still tells me to define the square class as an inner class of the polygon

so i think i did everything as required but it still tells me to define square as an inner class of the polygon class which i think i did when i did the (class Square : Polygon) when creating the class so what exactly is missing ?

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

        public Polygon(int numSides = 4)
        {
            NumSides = numSides;
        }
    }
    class Square : Polygon
    {
        public readonly int SideLength;
        public Square(int sideLength) : base (numSides)
        {
            SideLength = sideLength;
        }
    }
}

1 Answer

Mel Rumsey
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Hey AbduRahman Ezzeldin! You are so close!! The issue lies in where you are entering the parameter for the Polygon:

        public Polygon(int numSides = 4)
        {
            NumSides = numSides;
        }

We don't want to set the num sides = to 4 here. We just want the parameter to be take an int called numSides.

We enter 4 when we call the base class so that we can pass it in as an argument to the parent constructor. So, rather than typing numSides as the argument, this is where we want to add 4.

Hope this helps! Great job so far :D

thing is even if i do as you say it then asks if i got square as an inner class of polygon which is just like ? it is ?