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

C# C# Objects Encapsulation with Properties Expression Bodied Members

M. Brown
M. Brown
29,923 Points

Still stuck on this

No answers given yet...

Square.cs
namespace Treehouse.CodeChallenges
{
    class Square : Polygon
    {
        public double SideLength { get; private set; }

        public double Area 
        { 
            get { return SideLength * SideLength; } 
        }

        public Square(double sideLength) : base(4)
        {
            SideLength = sideLength;
        }

        public void Scale(double factor)
        {
            SideLength *= factor;
        }
    }
}
Polygon.cs
namespace Treehouse.CodeChallenges
{
    class Polygon
    {
        public int NumSides { get; private set; }

        public Polygon(int numSides)
        {
            NumSides = numSides;
        }
    }
}
M. Brown
M. Brown
29,923 Points

Just kidding. I was thinking about another topic. I'm still stuck on this though.

3 Answers

Steven Parker
Steven Parker
229,670 Points

It doesn't look like you've written any code yet.

This challenge is about using the syntax for expression-bodied members, also called the "arrow" notation. Without changing what they do, you'll convert a property and a method from the classic syntax to the "arrow" notation.

What you need to do here is very close to the examples given in the previous video. You might want to give it another look.

M. Brown
M. Brown
29,923 Points

The previous topic is what should be read. I just reposted this so I can get a proper answer.

Steven Parker
Steven Parker
229,670 Points

What do you mean by "previous topic"? Oh, now that I think about it, I helped you with this same issue before on this other question, but since you did not reply to my second answer I expected that you had already solved the challenge and moved on.

What did you do after the second hint? You had already solved task 1 before .. but your code here looks like you haven't started yet.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, M. Brown! I took a look at the other question you posed as linked by Steven Parker and from my perspective it seems like you've already gotten several detailed responses regarding the nature of the problem. In the code listed here, it doesn't appear as though you've written anything yet, but I'm sure you've written something that just isn't passing. I'd be very curious to know what that is so we might help you understand anything you might be missing.

Also, could you please elaborate on what you consider a "proper answer"? If you mean an explicit answer with code that you can copy and paste, you should be aware that Treehouse generally discourages giving straight out copy/paste answers when hints and advice will generally suffice.

Until we see your code, I might recommend reviewing 1:29 to 1:50 of the preceding video.

I look forward to seeing your code! :sparkles: