public static void Main1(string[] args) { Asteroid theAsteroid = new Asteroid(); ExplodingAsteroid theExplodingAsteroid = new ExplodingAsteroid(); SpaceShip theSpaceShip = new SpaceShip(); ApolloSpacecraft theApolloSpacecraft = new ApolloSpacecraft(); theAsteroid.CollideWith(theSpaceShip); theAsteroid.CollideWith(theApolloSpacecraft); theExplodingAsteroid.CollideWith(theSpaceShip); theExplodingAsteroid.CollideWith(theApolloSpacecraft); Console.WriteLine("-------------------------"); Asteroid theExplodingAsteroidRef = new ExplodingAsteroid(); SpaceShip theApolloSpacecraftRef = new ApolloSpacecraft(); theExplodingAsteroidRef.CollideWith(theApolloSpacecraftRef); }
public override void CollideWith(ApolloSpacecraft ship) { Console.WriteLine("ExplodingAsteroid hit an ApolloSpacecraft"); }
public virtual void CollideWith(ApolloSpacecraft ship) { Console.WriteLine("Asteroid hit an ApolloSpacecraft"); }