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 trialjose rego
2,663 PointsHaving Trouble with Challange Task 1 of 1 Virtual Properties? Hint! Read Question very carefully. :).
For those that get stuck on Intermediate C# -> Polymorphism -> Virtual Properties (Challenge Task 1 of 1) re-read this question slowly and see what you enter is exactly what it ask for. Check syntax, spelling, capitalization(hint!) and you be good... Once will just smack yourself for this one.
Question: SequenceDetector now contains a Description property. In RepeatDetector, override the Description property to return "Detects repetitions".
Will give you a real good hint.. They are with " " in the question.
namespace Treehouse.CodeChallenges
{
class RepeatDetector : SequenceDetector
{
public override string Description => "Detects Repetitions";
public override bool Scan(int[] sequence)
{
if(sequence.Length < 2)
{
return false;
}
for(int i = 1; i < sequence.Length; ++i)
{
if(sequence[i] == sequence[i-1])
{
return true;
}
}
return false;
}
}
}
namespace Treehouse.CodeChallenges
{
class SequenceDetector
{
public virtual string Description => "";
public virtual bool Scan(int[] sequence)
{
return true;
}
}
}
1 Answer
Alan Mattan贸
Courses Plus Student 12,188 PointsJust put override in front of the variable (of child class). Remember to check if the parent master class variable is virtual. Is it virtual? if not include virtual to the variable in the class SequenceDetector
Steven Parker
231,248 PointsSteven Parker
231,248 PointsIt's always best to follow the directions.
I can't count how many times someone ran into trouble by writing something that compiles, but is not what the challenge asked for!