C#C
C#14mo ago
Ahata

Inheritance

Hello all,

I have an inheritance problem. When I create an object Entity x; and later I asign him the value x = new MovingEntity(Texture,Position), the values are not assigned onto x. Why?

class Entity
{
#region Values
private Vector2 lposition;
public Vector2 position
{
get{ return lposition;}
set{ lposition = position;}
}
private Texture2D ltexture;

public Texture2D texture
{
get{ return ltexture;}
set{ ltexture = texture;}
}

#endregion Values

#region Constructors
public Entity(){}
public Entity(Vector2 position)
{
this.position = position;
}
public Entity(Texture2D texture)
{
this.texture = texture;
}
public Entity(Texture2D texture, Vector2 position)
{
this.position = position;
this.texture = texture;
}

#endregion Constructors

#region Functions

#endregion Functions
}


class MovingEntity : Entity
{
#region Values
private float lspeed;
public float speed
{
get{ return lspeed; }
set{ lspeed = speed; }
}

#endregion Values

#region Constructors
public MovingEntity(){}

public MovingEntity(Texture2D texture,Vector2 position) : base(texture,position){}

#endregion Constructors

}
Was this page helpful?