We have an abstract class called Game.
public abstract class Game
{
protected Player player;
public virtual void InitPlayer()
{
// steps
player = new Player(xxxxxxx);
}
// Other methods manipulating data from player.
}
and there are two child classes of Game , let's say GameA and GameB.
public class GameA : Game
{
public override void InitPlayer()
{
base.InitPlayer();
}
}
However, Player Variable in Game Class is also Abstract, having PlayerGameA and PlayerGameB.
public abstract class Player
{
}
public class PlayerGameA : Player
{
}
Note that Player and PlayerGameA Constructors have same arguments.
Now I have a problem about creating an instance of Abstract Class in InitPlayer Method. The result what I want is unifying result when creating an instance of GameA and calling gameA.InitPlayer() will create playerGameA ,and still other methods from GameClass needs to be able to manipulate data from that player variable.