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 trialngoc luc tuan
1,022 Pointsi do exact like the video, however i got this error
treehouse:~/workspace$ mcs -out:TreehouseDefense.exe *.cs
ShieldedInvader.cs(7,32): error CS0246: The type or namespace name `patch' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
ngoc luc tuan
1,022 Pointsthank you very much for helping me. here is the snapshort https://w.trhou.se/8mkejeubt1
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! Close, but not quite! You have some typos. In your ShieldedInvader.cs you've typed this:
public ShieldedInvader(patch patch) : base(patch)
That should be:
public ShieldedInvader(Path path) : base(path)
Note the spelling change from "patch" to "path" and the capitalization of the "Path" class.
Good luck!
ngoc luc tuan
1,022 PointsHi there! thank for your help but i wrote
public ShieldedInvader(Path path) : base(path)
still i have error like this :
ShieldedInvader.cs(7,32): error CS0246: The type or namespace name `Patch' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
Jennifer Nordell
Treehouse TeacherIt sounds like you're not saving your file. Also you must recompile these after you make the changes. Here's what my ShieldedInvader.cs file looks like after the alterations:
namespace TreehouseDefense
{
class ShieldedInvader : Invader
{
private static System.Random _random = new System.Random();
public ShieldedInvader(Path path) : base(path)
{
}
public override void DecreaseHealth(int factor)
{
if (_random.NextDouble() < .5)
{
base.DecreaseHealth(factor);
}
else
{
System.Console.WriteLine("short at a shielded invader but no damage !");
}
}
}
}
Make sure this is saved properly. Then run this command in the console: mcs -out:TreehouseDefense.exe *.cs
. After that, run mono TreehouseDefense.exe
. When I follow these steps, the program compiles and runs. Good luck!
ngoc luc tuan
1,022 Pointsthank you very much.. it work
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi! This is going to be easiest to troubleshoot if we can see your code. The ideal way to do this would be to share a snapshot of your workspace!