group1.model.gameobject
Class GameObjFactory

java.lang.Object
  extended by group1.model.gameobject.GameObjFactory

public class GameObjFactory
extends java.lang.Object

A factory class to make a GameObj. Used by Environment. Please add to this class as you make GameObj's. (Add to the import statements and the createGameObj method.)

Uses the "factory" and "singleton" design patterns, as suggested by the TA. You can't actually use the constructor in this class. Use getInstance() instead.


Method Summary
 GameObj createGameObj(char typeCode, double x, double y)
          Given an alphabetic type code, construct the corresponding type of game object.
static GameObjFactory getInstance(PictureList[] p)
          Get an instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static GameObjFactory getInstance(PictureList[] p)
Get an instance of this class. (Singleton design pattern.)


createGameObj

public final GameObj createGameObj(char typeCode,
                                   double x,
                                   double y)
Given an alphabetic type code, construct the corresponding type of game object. Used when reading a text file for the initialization of the environment.

Parameters:
typeCode - the alphabetic type code, or '.' to specify no object.
x - The x-coordinate position.
y - The y-coordinate position.
Returns:
the newly constructed GameObj subobject using the default constructor for the subobject, or null if no object or if an invalid type code is specified.