import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;

public class TestSection7 extends Applet implements ActionListener{
	int counter = 0;
	int counter2 = 0;
	int[] x = {1, 1, 1, 1};
	int[] y = {1, 1, 1, 1};
	int shipX=0;
	int shipY=0;
	boolean[] cargoDrawn = {true, true, true, true};
	Timer timer;
	
	public void init(){
		timer = new Timer(50, this);
		timer.start();
	}
	
	public void paint(Graphics p){
		counter++;
		
		if(counter < 20){
		}
		else{
			x[counter2] = (x[counter2]+1)%2;
			y[counter2] = (y[counter2]+1)%2;
			counter2 = (counter2+1)%cargoDrawn.length;
			counter=0;
			if(x[0] != 0){
				cargoDrawn[0] = true;
				cargoDrawn[1] = true;
				cargoDrawn[2] = true;
				cargoDrawn[3] = true;
			}
		}
		
		p.setColor(Color.BLACK);
		p.fillRect(0, 0, 400, 400);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		if(!gameWon(x, y, cargoDrawn, shipX, shipY))
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		
		//####################################
		// CALLING AND TESTING YOUR CODE
		p.drawString("Game won?: "+gameWon(x, y, cargoDrawn, shipX, shipY), 2, 12);
		
		if(cargoDrawn[0])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("cargo 0 drawn? "+cargoDrawn[0], 2, 25);
		
		if(cargoDrawn[1])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("cargo 1 drawn? "+cargoDrawn[1], 2, 40);
		
		if(cargoDrawn[2])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("cargo 2 drawn? "+cargoDrawn[2], 2, 55);
		
		if(cargoDrawn[3])
			p.setColor(Color.RED);
		else
			p.setColor(Color.GREEN);
		p.drawString("cargo 3 drawn? "+cargoDrawn[3], 2, 70);
	}
	
	
	//------------------------------------------------------------------
	// method that checks for cargo collisions with the ship and returns true/false if the game has been won
	public boolean gameWon(int[] x, int[] y, boolean[] drawn, int shipX, int shipY){
		//####################################
		// FILL IN YOUR CODE HERE
		//####################################
	}
	
	
	//------------------------------------------------------------------
	// method that checks for a collision between the given cargo piece and the ship
	public boolean cargoCollision(int x, int y, int shipX, int shipY){
		if(x == shipX && y == shipY)
			return true;
		else
			return false;
	}
	
	
	//----------------------------------------------------------------------------------------------------
	// #####   RESPONSE TO USER INPUT METHODS   #######
	//----------------------------------------------------------------------------------------------------
	
	// timer went off, so repaint the window
	public void actionPerformed(ActionEvent event){
		repaint();
	}
}

