import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;

import javax.swing.Timer;

public class TestSection11 extends Applet implements ActionListener{

	int counter = 0;
	int[] asteroidX = {10, 40, 70, 100};
	int[] asteroidY = {120, 90, 60, 30};
	int[] asteroidSpeedX = {1, 1, 1, 1};
	int[] asteroidSpeedY = {1, 1, 1, 1};
	
	boolean retry = false;
	Timer timer;
	Timer timer2;
	
	public void init(){
		setSize(400,400);
		timer = new Timer(50, this);
		timer.start();
		timer2 = new Timer(2000, this);
		timer2.start();
	}
	
	public void paint(Graphics p){
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		
		p.setColor(Color.GRAY);
		for(int i=0; i<asteroidX.length; i++){
			p.fillRect(asteroidX[i], asteroidY[i], 20, 20);
			asteroidX[i] = asteroidX[i] + asteroidSpeedX[i];
			asteroidY[i] = asteroidY[i] + asteroidSpeedY[i];
		}
		
		if(retry){
			retry = false;
			for(int i=0; i<asteroidX.length; i++){
				
				
				//####################################
				// CALLING AND TESTING YOUR CODE
				asteroidX[i] = randomX();
				asteroidY[i] = randomY();
				asteroidSpeedX[i] = randomSpeedX();
				asteroidSpeedY[i] = randomSpeedY();
				
				
			}
		}
	}
	
	
	// global variable used by all of the randomized methods
	Random gen = new Random();
	//------------------------------------------------------------------
	// method that returns a random number within the speed bounds for asteroids
	public int randomSpeedX(){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that returns a random number within the speed bounds for asteroids
	public int randomSpeedY(){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that returns a random number within the x bounds of the window
	public int randomX(){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that returns a random number within the y bounds of the window
	public int randomY(){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		if(event.getSource().equals(timer2))
			retry = true;
		
		repaint();
	}
}