unc.cdva.gameengine.managers
Class ProblemManager

java.lang.Object
  extended by unc.cdva.gameengine.managers.ProblemManager
All Implemented Interfaces:
Manager

public class ProblemManager
extends java.lang.Object
implements Manager

The problem manager has the task of managing the lifecylce of problem objects. It creates them, allows access to them, and can destroy them.
The problem manager is meant to be used by the game engine in conjunction with the other 'managers.'
The problem manager is a singleton class, and there will always be either zero or one instances of the problem manager.
Note that the lifecycle of a problem object begins when a player places a reticle, and ends when the player fires at the placed reticle.

Author:
Dan Van Atta, Guillaume Conte

Method Summary
 void addProblem(javax.vecmath.Vector3f ret, javax.vecmath.Vector3f gun, Id id)
          Creates a problem object.
static ProblemManager getInstance()
          Retrieves the instance of the problem manager.
 Problem getProblem(Id id)
          Retrieves a problem by the id.
 void init()
          Used to re-initialize the problem manager.
 void removeProblem(Id id)
          Removes the problem with some id.
 int size()
          Returns the total number of problem objects that the problem manager is managing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ProblemManager getInstance()
Retrieves the instance of the problem manager.


removeProblem

public void removeProblem(Id id)
Removes the problem with some id.

Parameters:
id - The id of the problem to be removed.
Throws:
java.lang.IllegalArgumentException - if there is no problem with the id passed in by the problem.

addProblem

public void addProblem(javax.vecmath.Vector3f ret,
                       javax.vecmath.Vector3f gun,
                       Id id)
Creates a problem object.

Parameters:
ret - A vector3f representing the position of the placed reticle.
gun - A vector3f representing the position of the cannon.
id - The id to mark the problem with.

getProblem

public Problem getProblem(Id id)
Retrieves a problem by the id.

Parameters:
id - The id of a problem to retrieve.
Returns:
A problem object marked by a given id.
Throws:
java.lang.IllegalArgumentException - if there is no problem object with the given id.

size

public int size()
Returns the total number of problem objects that the problem manager is managing.

Specified by:
size in interface Manager
Returns:
The total number of objects managed by the manager.

init

public void init()
Used to re-initialize the problem manager. Use this to clear out all of the managed problems and to rever the problem manager to an initial state.

Specified by:
init in interface Manager