The requirements for this section are as follows:
import
statement at the top of the file to import the following class files and folders: java.applet.Applet
, java.awt.*
, java.awt.event.*
, javax.swing.Timer
, and java.util.Random
.public class BlankApplet extends Applet implements ActionListener, MouseListener, KeyListener {}
int
array variables cargoX
and cargoY
with 50 entries each.boolean
array variable cargoDrawn
with 50 entries.int
array variables asteroidX
, asteroidY
, asteroidSpeedX
and asteroidSpeedY
with 10 entries each.int
variables shipX
, shipY
, shipSpeedX
and shipSpeedY
with an initial value of 0 for each.Timer
object variable timer
.Random
object variable gen
. It can be declared using the new
key word and the object's constructor method.public void init(){}
public void resetWindow(){}
public void paint(Graphics page){}
public void assignLocations(int[] cargoX, int[] cargoY, int[] asteroidX, int[] asteroidY){}
public void assignSpeeds(int[] asteroidSpeedX, int[] asteroidSpeedY){}
public int randomSpeedX(){}
public int randomSpeedY(){}
public int randomX(){}
public int randomY(){}
public void drawCargo(int[] x, int[] y, boolean[] drawn, Graphics p){}
public void drawAsteroids(int[] x, int[] y, Graphics p){}
public void drawShip(int x, int y, Graphics p){}
public void drawScore(Graphics p){}
public void isGameOver(Graphics p){}
public boolean gameWon(int[] x, int[] y, boolean[] drawn, int shipX, int shipY){}
public boolean gameLost(int[] x, int[] y, int shipX, int shipY){}
public boolean asteroidCollision(int x, int y, int shipX, int shipY){}
public boolean cargoCollision(int x, int y, int shipX, int shipY){}
public int getScore(){}
public void updateAsteroidCoordinates(int[] asteroidX, int[] asteroidY, int[] asteroidSpeedX, int[] asteroidSpeedY){}
public int updateXCoordinate(int x, int speed){}
public int updateYCoordinate(int y, int speed){}
public void actionPerformed(ActionEvent event){}
public void keyPressed(KeyEvent event){}
public void keyTyped(KeyEvent event) {}
public void keyReleased(KeyEvent event) {}
public void mouseClicked(MouseEvent event){}
public void mouseEntered(MouseEvent event){}
public void mouseExited(MouseEvent event){}
public void mousePressed(MouseEvent event){}
public void mouseReleased(MouseEvent event){}
Code template where you can insert your portion of the code to test it is located here.
No test applet for this section.