net.sourceforge.jsurveyor
Class QuestionMultipleChoice

java.lang.Object
  extended bynet.sourceforge.jsurveyor.Question
      extended bynet.sourceforge.jsurveyor.QuestionMultipleChoice

public class QuestionMultipleChoice
extends net.sourceforge.jsurveyor.Question

Class to model multipechoice questions Besides what is implemented from its superclass it handles the list of possible answers for the multiplechoice question.

Version:
1.0
Author:
Claus Methmann Christensen, Anders Spliid Hansen, Esben Iversen Hansen, Lars H Jensen, Marcus Overheu, Thomas Ramdal, Peter Thomsen

Constructor Summary
QuestionMultipleChoice()
          Constructor for QuestionMultipleChoice
QuestionMultipleChoice(int questionID, java.lang.String text, boolean writeable, boolean required, boolean depends, java.util.ArrayList dependency, java.lang.String[] choice)
          Constructor for QuestionMultipleChoice, use through DataAccess.
QuestionMultipleChoice(java.lang.String text, boolean writeable)
          Constructor for QuestionMultipleChoice
QuestionMultipleChoice(java.lang.String text, java.lang.String[] choice, boolean writeable)
          Constructor for QuestionMultipleChoice.
 
Method Summary
 void addChoice(java.lang.String[] newchoice, int n)
          Adds an array of choices to the existing array of choices, starting from the nth position
 java.lang.String[] getChoice()
          This method returns the text of the different choices.
 java.util.ArrayList getDependency()
          Returns the ArrayList representation of dependency
 boolean getDepends()
          Does the question depend on a specific answer from another question for it to be asked?
 int getQuestionID()
          Returns the ID of the question.
 java.lang.String getText()
          Returns the question text.
 boolean getWriteable()
          Returns true if the question is writeable
 boolean isWriteable()
          Returns true if the question is writeable.
 void removeChoice(int n)
          Removes a choice at the nth position from the existing array of choices
 void removeDependency()
          Removes any dependency on the question.
 void setChoice(java.lang.String[] choice)
          Sets the text of the different choices.
 void setDependency(QuestionMultipleChoice question, int[] choices)
          Sets the dependency of this question to specific answers of a multiplechoice question.
 void setQuestionID(int questionID)
          Sets the ID of the question.
 void setText(java.lang.String text)
          Sets the question text.
 void setWriteable(boolean writeable)
          Sets the writable parameter.
 java.lang.String toString()
          Returns the questionID prefixed with a M to represent it is a multiplechoice.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuestionMultipleChoice

public QuestionMultipleChoice()
Constructor for QuestionMultipleChoice


QuestionMultipleChoice

public QuestionMultipleChoice(java.lang.String text,
                              boolean writeable)
Constructor for QuestionMultipleChoice

Parameters:
text - String
writeable - boolean

QuestionMultipleChoice

public QuestionMultipleChoice(java.lang.String text,
                              java.lang.String[] choice,
                              boolean writeable)
Constructor for QuestionMultipleChoice.

Parameters:
text - String
choice - String[]
writeable - boolean

QuestionMultipleChoice

public QuestionMultipleChoice(int questionID,
                              java.lang.String text,
                              boolean writeable,
                              boolean required,
                              boolean depends,
                              java.util.ArrayList dependency,
                              java.lang.String[] choice)
Constructor for QuestionMultipleChoice, use through DataAccess.

Parameters:
questionID - int
text - String
writeable - boolean
required - boolean
depends - boolean
dependency - ArrayList
choice - String[]
Method Detail

getChoice

public java.lang.String[] getChoice()
This method returns the text of the different choices.

Returns:
String[]

setChoice

public void setChoice(java.lang.String[] choice)
               throws java.lang.IllegalAccessException
Sets the text of the different choices.

Parameters:
choice - String[]
Throws:
java.lang.IllegalAccessException

addChoice

public void addChoice(java.lang.String[] newchoice,
                      int n)
               throws java.lang.IllegalAccessException
Adds an array of choices to the existing array of choices, starting from the nth position

Parameters:
newchoice - String[]
n - int
Throws:
java.lang.IllegalAccessException - .

removeChoice

public void removeChoice(int n)
                  throws java.lang.IllegalAccessException
Removes a choice at the nth position from the existing array of choices

Parameters:
n - int
Throws:
java.lang.IllegalAccessException

toString

public java.lang.String toString()
Returns the questionID prefixed with a M to represent it is a multiplechoice. Returns a string representation of the object

Returns:
String

getQuestionID

public int getQuestionID()
Returns the ID of the question.

Returns:
int

setQuestionID

public void setQuestionID(int questionID)
Sets the ID of the question.

Parameters:
questionID - int

getText

public java.lang.String getText()
Returns the question text.

Returns:
String

setText

public void setText(java.lang.String text)
             throws java.lang.IllegalAccessException
Sets the question text. Throws IllegalAccessException if the question is active

Parameters:
text - String
Throws:
java.lang.IllegalAccessException

getDepends

public boolean getDepends()
Does the question depend on a specific answer from another question for it to be asked? Returns true if that is the case, otherwise it returns false.

Returns:
boolean

setDependency

public void setDependency(QuestionMultipleChoice question,
                          int[] choices)
                   throws java.lang.IllegalAccessException
Sets the dependency of this question to specific answers of a multiplechoice question.

Parameters:
question - QuestionMultipleChoice
choices - int[]
Throws:
java.lang.IllegalAccessException
PRE condition:
the numbers in the integer array must match possible choices in the dependency question.

removeDependency

public void removeDependency()
                      throws java.lang.IllegalAccessException
Removes any dependency on the question.

Throws:
java.lang.IllegalAccessException

getDependency

public java.util.ArrayList getDependency()
Returns the ArrayList representation of dependency

Returns:
ArrayList

isWriteable

public boolean isWriteable()
Returns true if the question is writeable.

Returns:
boolean

setWriteable

public void setWriteable(boolean writeable)
Sets the writable parameter.

Parameters:
writeable - boolean

getWriteable

public boolean getWriteable()
Returns true if the question is writeable

Returns:
boolean