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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Carsten Dollerup](https://secure.gravatar.com/avatar/041b10570e519fe1cc98014debbe0ab4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Carsten Dollerup
9,278 PointsIs this Challenge faulty?!
How does this not work... Tried (I think) everything. Challenge seems broken to me...
namespace Treehouse.CodeChallenges
{
class Square : Polygon
{
public double SideLength { get; private set; }
public Square(double sideLength) : base(4)
{
SideLength = sideLength;
public double Area
{
get { return SideLength * SideLength; }
}
}
}
}
namespace Treehouse.CodeChallenges
{
public class Polygon
{
public int NumSides { get; private set; }
public Polygon(int numSides)
{
NumSides = numSides;
}
}
}
3 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIt looks like you put your property inside the constructor.
Just move it out of the constructor and it should compile and pass the challenge.
![Carsten Dollerup](https://secure.gravatar.com/avatar/041b10570e519fe1cc98014debbe0ab4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Carsten Dollerup
9,278 PointsOk, thanks again, but that wasn't my "issue" :-) My thoughts were that by moving the Area property outside of the Square constructor it's not "locked" to the Square subclass, but I must be missing something here, as judging from your answer it clearly isn't correct how I think of it :-)
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou moved it out of the constructor, but not out of the class. It is still a method of the Square class.
![Carsten Dollerup](https://secure.gravatar.com/avatar/041b10570e519fe1cc98014debbe0ab4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Carsten Dollerup
9,278 PointsOk. Thanks a lot, Steven! Very, very gratious of you to help me with three answers. Thank you again :-)
Carsten Dollerup
9,278 PointsCarsten Dollerup
9,278 PointsThanks for you help Steven. That did the trick. I'm confused, however, how it makes sense to have the Area computed property within the Polygon class description instead of within the Square class. Esp. as some polygons wouldn't have the correct area calculated from the Area property...? I realize this isn't a problem to the C# programming in and of itself, I just don't get the logic of the Challenge... (?) Am I missing something here? In other words, how would I make sure the correct Area was calculated no matter how many sides to the Polygon object in a "real world situation"? Would I create a method that assesses the number of sides before calculating the Area instead of a computed property?
Steven Parker
230,688 PointsSteven Parker
230,688 PointsIn this example, the Square class has an Area property but the Polygon class does not.
It wouldn't make sense to attempt to provide an Area for a generic polygon knowing only the number of sides, that's not enough information to do the job in all cases. But we can do it for the Square because we know the side length (and the fact that it is square).