0

I will start with an example first:

So, Player is a child class, and Entity is a parent class.

Player:

    class Player : Entity
    {
        public override int Speed   { get; set; }
    }

Entity:

    abstract class Entity : Animation
    {
        public Moving Movement { get; set; }
        public abstract int Speed { get; set; }
    }

Note: Moving is an enum, which contains: Up, Down, Left, Right, None

So as you can see, I have overiden property in Player class, and I have a normal public property in Entity class.

When I make an instance of a Player, I can access both overriden Speed from Player class, and Movement from my Entity class.

Player player = new Player();
player.Speed = 1;
player.Movement = Moving.None;

So when should I make a property abstract, and when should I not ?

0 Answers0