|
AP® Computer Science Marine Biology Simulation | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--MBSFactory
AP® Computer Science Marine Biology Simulation:
The MBSFactory
class provides a set of static methods
for constructing objects in the Marine Biology Simulation program,
such as fish and environments, as well as tracking the available
classes to use in constructing those objects.
The MBSFactory
class is
copyright© 2002 College Entrance Examination Board
(www.collegeboard.com).
Constructor Summary | |
MBSFactory()
|
Method Summary | |
static void |
addBoundedEnvClassNames(java.lang.String[] classNames)
Adds bounded environment classes to the set maintained by the factory. |
protected static void |
addClassesToFactory(java.lang.String[] classNames,
java.lang.String whichCategory)
Helper to add new classes to the factory. |
static void |
addEnvObjClassNames(java.lang.String[] classNames)
Adds environment object classes to the set maintained by the factory. |
static void |
addUnboundedEnvClassNames(java.lang.String[] classNames)
Adds unbounded environment classes to the set maintained by the factory. |
static java.util.Set |
boundedEnvClasses()
Returns the set of bounded environment classes known to the factory. |
static Environment |
constructEnv(java.lang.Class cls)
Creates an instance of an Environment using the default constructor of the given class. |
static Environment |
constructEnv(java.lang.Class cls,
int numRows,
int numCols)
Creates an instance of an Environment using the 2-argument constructor of the given class. |
static java.lang.Object |
constructEnvObject(java.lang.Class cls,
Environment env,
Location loc)
Creates an instance of the given environment object class using a two-argument constructor that takes an environment and a location. |
static java.lang.Object |
constructEnvObject(java.lang.Class cls,
Environment env,
Location loc,
Direction dir)
Creates an instance of the given environment object class using a three-argument constructor that takes an environment, a location, and a direction. |
static java.lang.Object |
constructEnvObject(java.lang.Class cls,
Environment env,
Location loc,
Direction dir,
java.awt.Color color)
Creates an instance of the given environment object class using a four-argument constructor that takes an environment, a location, a diredction, and a color. |
static java.lang.Object |
constructObject(java.lang.Class cls,
java.lang.Class[] parameterTypes,
java.lang.Object[] parameters)
Creates an object of the given class. |
static java.util.Set |
envObjectClasses()
Returns the set of environment object classes known to the factory. |
protected static boolean |
hasCorrectCtor(java.lang.Class cls,
java.lang.Class requiredCls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable. |
static boolean |
hasFourArgCtor(java.lang.Class cls)
Reports wehther a given environment object class has an accessible four-arg constructor that takes Environment, Location, Direction, and Color. |
static boolean |
isValidEnvClass(java.lang.Class cls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable to Environment. |
static boolean |
isValidEnvObjectClass(java.lang.Class cls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable to Locatable. |
static java.util.Set |
unboundedEnvClasses()
Returns the set of unbounded environment classes known to the factory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MBSFactory()
Method Detail |
public static java.lang.Object constructObject(java.lang.Class cls, java.lang.Class[] parameterTypes, java.lang.Object[] parameters)
cls
- class of new objectparameterTypes
- parameter types expected by constructor
for classparameters
- actual parameters to pass to constructorMBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static java.lang.Object constructEnvObject(java.lang.Class cls, Environment env, Location loc)
cls
- class of new environment objectenv
- environment in which this object will actloc
- location the object will occupyMBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static java.lang.Object constructEnvObject(java.lang.Class cls, Environment env, Location loc, Direction dir)
cls
- class of new environment objectenv
- environment in which this object will actloc
- location the object will occupydir
- direction the object will faceMBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static java.lang.Object constructEnvObject(java.lang.Class cls, Environment env, Location loc, Direction dir, java.awt.Color color)
cls
- class of new environment objectenv
- environment in which this object will actloc
- location the object will occupydir
- direction the object will facecolor
- color of the objectMBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static Environment constructEnv(java.lang.Class cls)
cls
- class of new environmentMBSException
- if an environment of the specified class cannot be
constructedpublic static Environment constructEnv(java.lang.Class cls, int numRows, int numCols)
cls
- class of new environmentMBSException
- if an environment of the specified class cannot be
constructed with the given number of rows and columnspublic static java.util.Set envObjectClasses()
addEnvObjClassNames
method.public static java.util.Set boundedEnvClasses()
addBoundedClassNames
method.public static java.util.Set unboundedEnvClasses()
addUnboundedClassNames
method.protected static void addClassesToFactory(java.lang.String[] classNames, java.lang.String whichCategory)
classNames
- an array of class nameswhichCategory
- descriptive name for category
(e.g., "bounded environment")public static void addEnvObjClassNames(java.lang.String[] classNames)
classNames
- an array of environment object class namespublic static void addBoundedEnvClassNames(java.lang.String[] classNames)
classNames
- an array of bounded environment class namespublic static void addUnboundedEnvClassNames(java.lang.String[] classNames)
classNames
- an array of unbounded environment class namespublic static boolean isValidEnvClass(java.lang.Class cls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
public static boolean isValidEnvObjectClass(java.lang.Class cls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
protected static boolean hasCorrectCtor(java.lang.Class cls, java.lang.Class requiredCls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
public static boolean hasFourArgCtor(java.lang.Class cls)
|
AP® Computer Science Marine Biology Simulation | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |