|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectexe.questionCollection
public class questionCollection
This class is used to store a collection of question objects.
A questionCollection object contains a reference to the
PrintWriter output stream to which it is to write
question information and maintains a Vector of the
questions that have been added to the collection. Using a
questionCollection in a script-producing program provides a
simple mechanism for managing questions and properly inserting
them into the showfile.
Modifications to this class have been made that allow the user to use
probability functions to control the insertion of questions
into the showfile. These changes make it possible to evenly distribute
questions throughout an animation and precisely control when
questions are asked.
In order to use the question support provided by
questionCollection, a script-producing program must import the
package exe. Note that a questionCollection only
allows the insertion of questions of the types
fibQuestion, mcQuestion, msQuestion,
and tfQuestion. Therefore, this class is intended for use with
programs that produce scripts in the ANIMAL or old GAIGS formats.
| Constructor Summary | |
|---|---|
questionCollection(java.io.PrintWriter out)
Constructs a new questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information. |
|
questionCollection(java.io.PrintWriter out,
int numq)
Constructs a new questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information and the maximum number of questions
that can be added to this collection. |
|
questionCollection(java.io.PrintWriter out,
int numq,
int nump)
Constructs a new questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information, the maximum number of questions that
can be added to this collection, and the number of possibilities to add
questions to this collection. |
|
| Method Summary | |
|---|---|
boolean |
addQuestion(question q)
Adds a question to this questionCollection. |
boolean |
addQuestion(question q,
boolean always)
Adds a question to this questionCollection and
gives the user the option to ignore the probability functions to ensure
that the question will be added. |
void |
adjustProbability()
Recalculates the probability of inserting a question into
this questionCollection. |
void |
animalInsertQuestion(int index)
Deprecated. Replaced by animalInsertQuestion(String). Since
calls to addQuestion do not always add a
question to this collection (due to the
probability functions), a question's
id might be different from its index in the
Vector, causing this method to insert a
different question than the programmer
intended. Therefore, this method is unreliable when using
the new probability functions and remains only to support
old code. |
void |
animalInsertQuestion(java.lang.String ID)
Inserts the ANIMAL format reference for the question with
id ID in this questionCollection at the
current point in the showfile. |
void |
animalWriteQuestionsAtEOSF()
Writes out the information for each question stored in this
collection in the ANIMAL format. |
void |
incPos()
Increments countp and then adjusts the probability of
inserting a question accordingly. |
void |
insertQuestion(int index)
Deprecated. Replaced by insertQuestion(String). Since calls to
addQuestion do not always add a
question to this collection (due to the
probability functions), a question's
id might be different from its index in the
Vector, causing this method to insert a
different question than the programmer
intended. Therefore, this method is unreliable when using
the new probability functions and remains only to support
old code. |
void |
insertQuestion(java.lang.String ID)
Inserts the old GAIGS format reference for the question
with id ID in this questionCollection at the
current point in the showfile. |
void |
writeQuestionsAtEOSF()
Writes out the information for each question stored in this
collection in the old GAIGS format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public questionCollection(java.io.PrintWriter out)
questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information.
This constructor creates a questionCollection that does not
use any of the new probability functions. Therefore, this constructor
can be used by script-producing programs that use different methods to
determine when questions should be added to the showfile.
out - Indicates the PrintWriter output stream to which
this questionCollection should write its
information.
public questionCollection(java.io.PrintWriter out,
int numq)
questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information and the maximum number of questions
that can be added to this collection.
Invoking this constructor creates a questionCollection that
uses the value passed to numq to determine the probability
of adding a question when addQuestion is
called.
out - Specifies the PrintWriter output stream to
which this questionCollection should write its
information.numq - Indicates the maximum number of questions that
can be added to this questionCollection. This
value is used to determine the probability of adding
questions to this collection.
public questionCollection(java.io.PrintWriter out,
int numq,
int nump)
questionCollection by specifying the
PrintWriter output stream to which this collection should
write its information, the maximum number of questions that
can be added to this collection, and the number of possibilities to add
questions to this collection.
Calling this constructor creates a questionCollection that
uses the value passed to numq to determine the probability
of adding a question when addQuestion is
called and uses the value passed to nump to evenly
distribute the questions throughout the showfile's
snapshots.
out - Indicates the PrintWriter output stream to
which this questionCollection should write its
information.numq - Sets the maximum number of questions that can
be added to this questionCollection. This value
is used to determine the probability of adding
questions to this collection.nump - Specifies the number of opportunities to add a
question to this
questionCollection. This number is used to
evenly distribute questions throughout the
showfile.| Method Detail |
|---|
public boolean addQuestion(question q)
question to this questionCollection.
If this collection was created by calling
questionCollection(PrintWriter), the question
will always be added to this collection. If either of the other two
constructors was used to create this questionCollection,
the probability functions will be used to determine whether the
question is added to this collection. Note that, in these
cases, the question will never be added if the maximum
number of questions has been reached.
q - Indicates the question that should be added to
this collection. Note that only fibQuestion,
mcQuestion, msQuestion, and
tfQuestion objects can be added to a
questionCollection; any other type of object will
never be added to this collection.
true if the specified
question was added to this collection; otherwise,
false is returned.
public boolean addQuestion(question q,
boolean always)
question to this questionCollection and
gives the user the option to ignore the probability functions to ensure
that the question will be added.
This method functions identically to addQuestion(question),
except that it allows the user to force adding the question
to this collection as long as the maximum number of
questions has not already been reached.
q - Indicates the question that should be added
to this collection. Note that only
fibQuestion, mcQuestion,
msQuestion, and tfQuestion
objects can be added to a questionCollection;
any other type of object will never be added to this
collection.always - Specifies if the probability functions should be used to
determine whether the question is added or
ignored. A value of true bypasses the
probability functions and causes the question
to be added as long as the maximum number of
questions has not already been reached. A
value of false makes this method function
identically to addQuestion(question).
true if the given
question was added to this collection;
otherwise returns false.public void incPos()
countp and then adjusts the probability of
inserting a question accordingly.
This method is used internally by the class and should probably have
been made private but was left public to
ensure compatibility with old code. There will likely never be any need
to call on this method explicitly.
public void adjustProbability()
question into
this questionCollection.
This method is called by incPos() and should probably have
been made private but was left public to
ensure compatibility with old code. There will likely never be any need
to call on this method explicitly.
public void insertQuestion(int index)
insertQuestion(String). Since calls to
addQuestion do not always add a
question to this collection (due to the
probability functions), a question's
id might be different from its index in the
Vector, causing this method to insert a
different question than the programmer
intended. Therefore, this method is unreliable when using
the new probability functions and remains only to support
old code.
question
stored at index index in this
questionCollection's Vector of
questions at the current point in the showfile.
index - Specifies which question's reference should be
inserted into the showfile by giving its index in this
collection's Vector of questions.
If the value of index is not a valid index to
this Vector, no question
reference is inserted.public void insertQuestion(java.lang.String ID)
question
with id ID in this questionCollection at the
current point in the showfile.
This method does a linear search on the Vector of
questions to find the question with an
id that matches ID. If a match is found, the
reference for the matching question is inserted into the
current point in the animation file; otherwise, no change is made to the
showfile.
ID - Indicates the id value of the
question that should be asked in the current
snapshot of the animation. If no question is
found with an id that matches ID,
no question reference is inserted into the
showfile. If a match is found, a reference to the matching
question is inserted at the current point in the
specified PrintWriter output stream.public void animalInsertQuestion(int index)
animalInsertQuestion(String). Since
calls to addQuestion do not always add a
question to this collection (due to the
probability functions), a question's
id might be different from its index in the
Vector, causing this method to insert a
different question than the programmer
intended. Therefore, this method is unreliable when using
the new probability functions and remains only to support
old code.
question stored
at index index in this questionCollection's
Vector of questions at the current point
in the showfile.
index - Specifies which question's reference should be
inserted into the showfile by giving its index in this
collection's Vector of questions.
If the value of index is not a valid index to
this Vector, no question
reference is inserted.public void animalInsertQuestion(java.lang.String ID)
question with
id ID in this questionCollection at the
current point in the showfile.
This method does a linear search on the Vector of
questions to find the question with an
id that matches ID. If a match is found, the
reference for the matching question is inserted into the
current point in the animation file; otherwise, no change is made to the
showfile.
ID - Indicates the id value of the
question that should be asked in the current
snapshot of the animation. If no question is
found with an id that matches ID,
no question reference is inserted into the
showfile. If a match is found, a reference to the matching
question is inserted at the current point in the
specified PrintWriter output stream.public void writeQuestionsAtEOSF()
question stored in this
collection in the old GAIGS format.
Calling this method after the rest of the animation file has been
written causes the question information to be appended to
the end of the file so that the questions can be added to
the animation at the snapshots in which their references appear.
public void animalWriteQuestionsAtEOSF()
question stored in this
collection in the ANIMAL format.
Calling this method after the rest of the animation file has been
written causes the question information to be appended to
the end of the file so that the questions can be added to
the animation at the snapshots in which their references appear.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||