Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
InvaderFactory

spaceinvaders
Class InvaderFactory

java.lang.Object  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
()
           
 
Method Summary
static ( g)
          Used in the inital game setup, returns instances of whatever is the "default" invader.
static ( 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  defaultInvader( 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  newInvader( 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.