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 Loops and Final Touches Playing the Game

Koray Erkan
Koray Erkan
1,235 Points

Why am I losing?

when I debug the exe, it prints "Player lost", contrary to the video.

Steven Parker
Steven Parker
231,268 Points

To make it possible for someone to help, you'll need to post your code, or (even better) use the snapshot function in the workspace and provide the link to it.

2 Answers

William Schultz
William Schultz
2,926 Points

The problem is you are checking if the invader is neutralized by only checking if it's health is lower than 0 rather than checking if it is < or = 0. So when the invaders health reaches 0, your code still returns false for if it is neutralized instead of true.

Change:

public bool IsNeutralized
{
  get
  {
    return (Health <= 0);                    //Changed Health < 0 to Health <= 0
  }
}