More Properties

Now, the invaders need to have a property if they able to reach the end of game. We called is HasScoredin Invader class.

public bool HasScored { get { return _pathStep >= _path.Length; } }

Unfortunately, our Path class doesn't have Length property. So, we need to add it.

public int Length => _path.Length;

Now, we would like to know if the Invader still alive or not, so we create method called IsNeutralized. And we could create another method called IsActive which valued not (IsNeutralized or HasScored).

public bool IsNeutralized => Health <= 0;

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

results matching ""

    No results matching ""