Class Obstacle

java.lang.Object
  extended byObstacle

public class Obstacle
extends java.lang.Object

Author:
bachmaer Super class for all static objects in the space game. Maintains position Obstacle objects.

Field Summary
(package private) static java.util.Random rand
           
(package private)  int xPosition
           
(package private)  int yPosition
           
 
Constructor Summary
Obstacle()
          Default constructor.
Obstacle(int x, int y)
          Creates and obstacle with the specified location.
 
Method Summary
 void draw(java.awt.Graphics g)
          Default rendering method.
 int getXPosition()
          Accessor method for the xPosition.
 int getYPosition()
          Accessor method for the yPosition.
 void setX(int x)
          Mutator method for the x positon.
 void setY(int y)
          Mutator method for the y positon.
 java.lang.String toString()
          Constructs a string representation of the the obstacle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xPosition

int xPosition

yPosition

int yPosition

rand

static java.util.Random rand
Constructor Detail

Obstacle

public Obstacle()
Default constructor. Creates and obstacle with a randomly generated position.


Obstacle

public Obstacle(int x,
                int y)
Creates and obstacle with the specified location.

Parameters:
x - horizontal position of the obstacle
y - vertical position of the obstacle
Method Detail

getXPosition

public int getXPosition()
Accessor method for the xPosition.

Returns:
current x position

getYPosition

public int getYPosition()
Accessor method for the yPosition.

Returns:
current y position

setX

public void setX(int x)
Mutator method for the x positon. If input parameter contains an illegal position it leaves the position unchanged.

Parameters:
x - new x position

setY

public void setY(int y)
Mutator method for the y positon. If input parameter contains an illegal position it leaves the position unchanged.

Parameters:
y - new y position

draw

public void draw(java.awt.Graphics g)
Default rendering method. Renders the Obstacle as a yellow square.


toString

public java.lang.String toString()
Constructs a string representation of the the obstacle.

Returns:
string representation of the SpaceCraft