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 Encapsulation with Properties Property Practice

Yu-Yang Hsiao
Yu-Yang Hsiao
6,295 Points

I don't quite understand the last code Jeremy wrote

What dose this code mean exactly? Does it mean that if IsNeutralized or HasScored return false then Invader is active?

public bool IsActive =>!(IsNeutralized ||HasScored );

2 Answers

Kent Åsvang
Kent Åsvang
18,823 Points
public bool IsActive =>!(IsNeutralized ||HasScored );

in pseudocode is says :

if IsNeutralized is true or HasScored is true, IsActive is set to False. But as Long as both return false, invader is active.

Hope that helped.

Yu-Yang Hsiao
Yu-Yang Hsiao
6,295 Points

OH~I see. Thanks for the perfect answer. Really appreciate it.

Yes, Kent is correct. We declare a boolean which returns either true or false. The '!' or 'not' operator makes it so that if the invader is not neutralized or has not made it to the end of the path, it returns true and tells the game that the invader is still alive. I have not continued with the development of the game as of this point, but this looks like a value that could be used later on when we program different methods such as feedback like 'You lose!' or 'You win!'