I can't understund for what is constructor in abstract class, because as far as I can understand properties in abstract class, that i can overide, i can't get point of creating construcor...
Correct me if i'm wrong - Abstract classes inform what should be declared in the derived class.
I wrote the code like below, shoud i remove constructor from abstract class and is constructor in derived class is enough? How to create object of Player class? Shoud i code: Actor player = new Player(); or Player player = new Player(); or something else? :)
(I know the access modifiers are bad, but it's not a point of my study)
{
//Actor.cs
public abstract class Actor
{
public abstract Dictionary<int, int> ActorPosition { get; set; }
public Actor()
{
}
}
}
{
//Player.cs
public class Player : Actor
{
public override Dictionary<int, int> ActorPosition { get; set; }
public Player()
{
this.ActorPosition = new Dictionary<int, int>();
}
}
}
//Program.cs
Map map = new Map(5, 10);
Actor player = new Player();
map.printBoard(4, 3);
Console.WriteLine(player.ActorPosition.Values.ToList().IndexOf(0,0));