//Needed for the mouse
...
//Needed for the graphics
...

/**
 * The last defender of earth...
 *
 * Notice how this class has methods equivalent to those in the Alien class.
 */
public class Ship implements MouseListener, MouseMotionListener {

    public static int SHIP_HEIGHT = 25;
    public static int SHIP_WIDTH  = 15;  

    private int x = 0;
    private int heightPosition = 0;    

    SpaceInvaders spaceInvaders = null;

    //We are only going to allow one shot at a time
    Shot shot = null;

    boolean hitState = false;

    /**
     *
     */
    public Ship(SpaceInvaders si) {
        ...
	//Dynamically work out the starting position of the ship
        ...
    }

    /**
     * We will use the mouse to fly our ship
     */ 
    public void mouseMoved(MouseEvent me) {
        ...
            //Stop the ship moving off the screen
	    ...
            //Set the new x position
	    ...		
    }    

    /**
     * Unused
     */
    public void mouseDragged(MouseEvent me) {

    }      

    /**
     * Restart the game as we put the mouse back over the screen
     */    
    public void mouseEntered(MouseEvent me) {
        ...
    }

    /**
     * Pause the game as we move the mouse off the screen
     */    
    public void mouseExited(MouseEvent me) {
        ...
    }

    /**
     *
     */    
    public void mouseReleased(MouseEvent me) {

    }

    /**
     *
     */    
    public void mousePressed(MouseEvent me) {

    }
    
    /**
     * Fire a shot at the aliens - mouse click
     */    
    public void mouseClicked(MouseEvent me) {
	...
    }
        
    /**
     * Draw the image of the ship
     */    
    public void drawShip(Graphics g) {
        ...
	//If the shot is still alive, i.e. still on the screen
	...
    } 

    /**
     * Check if a shot fired by an alien hit the ship
     */
    public boolean checkShot(int xShot, int yShot) {

	//Is the ship currently alive?
	//if (hitState) {
            //If it's alreay been shot then return false;
	  //  return false;
	//}
	    
	    
        //First lets check the X range
        ...
            //X is ok, now lets check the Y range
            ...
    }    

    public void hitByAlien() {
        ...
    }

}
