static void Main(string[] args) { Asteroid a = new Asteroid(); ExplodingAsteroid ea = new ExplodingAsteroid(); SpaceShip s = new SpaceShip(); TieFighter tf = new TieFighter(); a.CollideWith(s); a.CollideWith(tf); ea.CollideWith(s); ea.CollideWith(tf); Console.WriteLine(); a = ea; s = tf; a.CollideWith(s); }
public override void CollideWith(ExplodingAsteroid a) { Console.WriteLine("ExplodingAsteroid hit a TieFighter"); }
public virtual void CollideWith(ExplodingAsteroid a) { Console.WriteLine("ExplodingAsteroid hit a SpaceShip"); }