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 trialshawn khah
15,082 Pointscan't solve challange 2 of 2
Challenge Task 2 of 2
In Increment.cs create a class named Increment that implements the IUnaryOperation interface. The Perform method should increment the value passed in by one. Important: In each task of this code challenge, the code you write should be added to the code from the previous task. Restart Preview Get Help Check Work IUnaryOperation.cs Increment.cs
1
namespace Treehouse.CodeChallenges
2
{
3
public class Increment : IUnaryOperation {
4
ā
5
public double Perform(double value) {
6
return value += 1;
7
}
8
}
9
}
10
ā
namespace Treehouse.CodeChallenges
{
interface IUnaryOperation
{
double Perform(double value);
}
}
namespace Treehouse.CodeChallenges
{
public class Increment : IUnaryOperation {
public double Perform(double value) {
return value += 1;
}
}
}
2 Answers
Steven Parker
231,198 PointsYour code looks fine, and it passes the challenge. Good job.
You didn't mention what kind of problem you were having. But I suggest you try again, and simply paste the answer from above into the challenge (that's what I did, and it passed).
shawn khah
15,082 Pointsthanks steven
Ricardo Ferreira
9,694 PointsRicardo Ferreira
9,694 PointsWhy would you implement the interface when the method in the class seems like a regular method.