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 trialFabiola Barrientos
9,467 PointsWhere do I put the new class?
No matter where I put "class Square : Polygon", it keep telling me the same thing error message: "Did you define your Square class as an inner class of the Polygon class? Be sure to define the Square class before or after the definition for the Polygon class. It seems like ive tried every spot posible and have no idea how this is supposed to be answered. When this was done in the video the person made a whole other document and that is not posible to do here.
namespace Treehouse.CodeChallenges
{
class Polygon
{
public readonly int NumSides;
public Polygon(int numSides) : base(4)
{
NumSides = numSides;
}
}
class Square : Polygon
{
public readonly int SideLength;
public Square(int sideLength)
{
SideLength = sideLength;
}
}
}
1 Answer
jb30
44,806 PointsThe Square class is in the correct place, but you modified the Polygon
class to default to having four sides rather than the Square
class.
Try changing public Polygon(int numSides) : base(4)
and public Square(int sideLength)
to public Polygon(int numSides)
and public Square(int sideLength) : base(4)
.
Fabiola Barrientos
9,467 PointsFabiola Barrientos
9,467 Pointsthank you so much it worked!! i kept getting an error message telling me the mistake was me placing the Square class in the incorrect place and didnt mention anything about the base placement.