Me han dicho que hacer mi clase abstracta:¿Métodos virtuales puros en C#?
public abstract class Airplane_Abstract
Y para hacer un método llamado mover
public virtual void Move()
{
//use the property to ensure that there is a valid position object
double radians = PlanePosition.Direction * (Math.PI/180.0);
// change the x location by the x vector of the speed
PlanePosition.X_Coordinate += (int)(PlanePosition.Speed * Math.Cos(radians));
// change the y location by the y vector of the speed
PlanePosition.Y_Coordinate += (int)(PlanePosition.Speed * Math.Sin(radians));
}
y que otros 4 métodos deben ser virtual "métodos virtuales puros". ¿Qué es eso exactamente?
Todos ellos se parecen a esto ahora:
public virtual void TurnRight()
{
// turn right relative to the airplane
if (PlanePosition.Direction >= 0 && PlanePosition.Direction < Position.MAX_COMPASS_DIRECTION)
PlanePosition.Direction += 1;
else
PlanePosition.Direction = Position.MIN_COMPASS_DIRECTION; //due north
}
Cuando interesa, para una discusión sobre las funciones virtuales y no virtuales puros puros (ventajas y desventajas), voy a egoístamente redirigir a [un blog] (http://whathecode.wordpress.com/2010/ 12/20/abstraction-is-everything /) de mí. :) –
lol. Voy a marcar que es una buena publicación. –