Class SpaceCraft

java.lang.Object
  extended bySpaceCraft
Direct Known Subclasses:
AlienSpaceCraft, OwnSpaceCraft

public class SpaceCraft
extends java.lang.Object

Author:
bachmaer, opyrchal Super class for all moving objects in the space game. Unique identifies each Spacecraft using a ip address and a port number. Maintains position and heading state for SpaceCraft objects.

Field Summary
(package private)  int heading
           
(package private)  java.net.InetAddress ID
           
(package private)  int IDport
           
(package private)  int xPosition
           
(package private)  int yPosition
           
 
Constructor Summary
SpaceCraft()
           
 
Method Summary
 void draw(java.awt.Graphics g)
          Default rendering method.
 boolean equals(SpaceCraft subject)
          Checks to see if this SpaceCraft has the same ID and port number as the input parameter.
 int getHeading()
          Accessor method for the heading.
 int getXPosition()
          Accessor method for the xPosition.
 int getYPosition()
          Accessor method for the yPosition.
 void setHeading(int heading)
          Mutator method for the heading.
 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 craft.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

java.net.InetAddress ID

IDport

int IDport

xPosition

int xPosition

yPosition

int yPosition

heading

int heading
Constructor Detail

SpaceCraft

public SpaceCraft()
Method Detail

getHeading

public int getHeading()
Accessor method for the heading.

Returns:
current heading

equals

public boolean equals(SpaceCraft subject)
Checks to see if this SpaceCraft has the same ID and port number as the input parameter.

Parameters:
subject - SpaceCraft being checked for equality
Returns:
true if the SpaceCraft have same ID and port, false otherwise

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

setHeading

public void setHeading(int heading)
Mutator method for the heading. If input parameter contains an illegal heading it leaves the heading unchanged.

Parameters:
heading - parmeter set to 1, 2, 3, or 4

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 SpaceCraft as a yellow circle.

Returns:
current x position

toString

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

Returns:
string representation of the SpaceCraft