Class Defender

java.lang.Object
  extended by Defender

public class Defender
extends java.lang.Object

A Lunar lander that can fire lasers


Constructor Summary
Defender(int startX, int startY, java.lang.String imageName)
          Constructs a Defender at the given location with the given image
 
Method Summary
 Laser fireWeapon()
          Return the bullet this Defender is about to fire.
 java.lang.String getImageName()
          Returns the filename of this Defender's image
 int getXPosition()
          Get the current x coordinate of the center of this Defender.
 int getYPosition()
          Get the current y coordinate of the center of this Defender.
 boolean isHitByLaser(Laser theLaser)
          Returns whether this Defender intersects this Laser
 void paint(java.awt.Graphics g)
          Paint this Defender onto the given Graphics object
 void recordHit()
          Updates the Object to record that it has been hit by a Laser.
 boolean removeMeFromGame()
          Returns true if this Defender is dead.
 void setXPosition(int newXPosition)
          Sets the x position to the given position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Defender

public Defender(int startX,
                int startY,
                java.lang.String imageName)
Constructs a Defender at the given location with the given image

Parameters:
startX - the x position to start at
startY - the y position to start at
imageName - the filename for the image to use
Method Detail

setXPosition

public void setXPosition(int newXPosition)
Sets the x position to the given position

Parameters:
newXPosition -

fireWeapon

public Laser fireWeapon()
Return the bullet this Defender is about to fire.

Returns:
The bullet this Defender is about to fire.

getImageName

public java.lang.String getImageName()
Returns the filename of this Defender's image

Returns:
the filename of this Defender's image

getXPosition

public int getXPosition()
Get the current x coordinate of the center of this Defender.

Returns:
The current x coordinate of the center of this Defender.

getYPosition

public int getYPosition()
Get the current y coordinate of the center of this Defender.

Returns:
The current y coordinate of the center of this Defender.

isHitByLaser

public boolean isHitByLaser(Laser theLaser)
Returns whether this Defender intersects this Laser

Parameters:
theLaser -
Returns:
true if this Defender intersects this Laser

removeMeFromGame

public boolean removeMeFromGame()
Returns true if this Defender is dead.

Returns:
true if the Defender is dead

recordHit

public void recordHit()
Updates the Object to record that it has been hit by a Laser. This method is called every time the Defender is struck by a Laser.


paint

public void paint(java.awt.Graphics g)
Paint this Defender onto the given Graphics object

Parameters:
g - the Graphics object to draw onto