Property Initial Value

In a game, towers shoot and hit the invader then invader died. We also need a variable to tell how much health the invader has remaining.

We should write a constructor for Invader's health.

public int Health { get; private set; } = 2;

And

public void decreaseHealth(int factor)
{
    Health -= factor;
}

results matching ""

    No results matching ""