示例#1
0
            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);
            }
示例#2
0
 public override void CollideWith(ApolloSpacecraft ship)
 {
     Console.WriteLine("ExplodingAsteroid hit an ApolloSpacecraft");
 }
示例#3
0
 public virtual void CollideWith(ApolloSpacecraft ship)
 {
     Console.WriteLine("Asteroid hit an ApolloSpacecraft");
 }