Now that we have a functioning space ship, we'll add some asteroids to our game. We'll write an asteroid class that extends Floater
.
- Write an Asteroid class that extends Floater. Make sure it's not inside the curly braces of any other class. You will need to
write a constructor and the code to "finish" the
abstract
methods in the Floater class - Add a
int
member variable of theAsteroid
class. It will hold the speed of rotation for each asteroid. Make sure that this is initialized to have an equal probablility of being positive or negative. Also make sure to declare it appropriately (should it bepublic
orprivate
?) - "Override" the
move()
method of the Floater class by writing a newmove()
method in the Asteroid class that also rotates each Asteroid at its own speed - Now add just a single asteroid to your applet. Start by just calling the Asteroid's
show()
function. Make sure you can see it and are happy with its shape before going to the next step. - Now add the code that moves and rotates the Asteroid
- Modify your code so that you have an array of Asteroids.
- Submit the URL of your working program to the school loop locker
If you have extra time, you might try to figure out how to check to see if the ship has collided with an asteroid.