spaceinvaders
Class InvaderFactory

java.lang.Object
  extended by spaceinvaders.InvaderFactory

public class InvaderFactory
extends java.lang.Object

Static class - its methods are used to generate instances of classes that implement the Invader interface.


Constructor Summary
InvaderFactory()
           
 
Method Summary
static SpaceInvader defaultInvader(Game g)
          Used in the inital game setup, returns instances of whatever is the "default" invader.
static SpaceInvader newInvader(Game g)
          Returns an invader of some randomly chosen specialized type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvaderFactory

public InvaderFactory()
Method Detail

defaultInvader

public static SpaceInvader defaultInvader(Game g)
Used in the inital game setup, returns instances of whatever is the "default" invader.

Parameters:
g - Reference to the Game object - passed to Invaders in their constructors (it gets used to do some operations on (x,y) coordinates.
Returns:
A reference to a new invader.

newInvader

public static SpaceInvader newInvader(Game g)
Returns an invader of some randomly chosen specialized type. The mechanism will arrange that different invaders have different probabilities of occurrence - high valued and dangerous invaders should be less common that lower valued invaders.

Parameters:
g - Reference to the Game object, passed to invaders in their constructors and used for some operations involving (x,y) coordinates.
Returns:
An invader of some randomly chosen type.