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# Intermediate C# Polymorphism Virtual Methods

I'm never getting a shielded invade response from the console.

I've looked this up and down, but I can't seem to figure out why I'm never getting the response "shot at a shielded invader...".

I've even tried a few different things to force that response (changed my array of invaders in Game.cs to only consist of ShieldedInvaders and changed the "chances" in the ShieldedInvader.DecreaserHealth() method to always result false by asking if the random double is < 0) but still no shielded invader response.

Here is a workspace snapshot. https://w.trhou.se/fbkcq12fpc

3 Answers

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

Hi there! I took the liberty of forking your workspace and taking a look. When I compile and run the code I get almost all "Shot at a shielded invader but it sustained no damage". I know this may sound silly, but are you positive that you recompiled the code after you changed it? I can not imagine why I would have different results than what you're getting.

Let me know if this helps or if you're still stuck! :sparkles:

Yeah, I'm actually doing the mcs -out:name.exe *cs && mono name.exe commando every time, so technically its recompiling it every time I try to execute it.

WAAAAIT I'm an idiot. my command is this;

mcs -out:TreehouseDefense *.cs && mono TreehouseDefence.exe

and it should be -out:TreehouseDefense.exe; I'm compiling to one file name without an extension and then running the original .exe from before.

Figure it out

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

Jeff Spurlock You're most definitely not an idiot. You're human. LOL we've all done things like that :smiley: It's why a second pair of eyes is spectacular.

Thank you for asking the question...I did the exact same thing as Jeff.

I'm ashamed to say I have spent the past hour replaying this video, going through my code with a finetoothed comb contemplating buying an actual magnifying glass(I know ctrl+scroll^... still) having made the same mistake as Jeff...