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 trialRamone Robertson
2,348 PointsHow do I create a class in the challenge quizzes?
I'm in the C# objects course and the challenge wants me to create a new Polygon named Square that inherits from the Polygon class. I do not see an option to create a new file ect.. so I edited what they gave me. The error says did I delete the polygon class?
namespace Treehouse.CodeChallenges
{
class Square : Polygon
{
public readonly int NumSides;
public readonly int SideLength;
public Square(int numSides) : base(int numSides)
{
SideLength = sideLenth;
}
}
}
1 Answer
Steven Parker
231,271 PointsYou need to keep all the original code.
Add your new class to the same file, sharing the same namespace.
The Square class won't need it's own NumSides, it inherits that. Also remember the challenge said you should pass the value 4 to the base constructor.
Ramone Robertson
2,348 PointsRamone Robertson
2,348 PointsThank you, Steven! I got it working!