talx x1.0.5

talx.games.tech
Class QuestionAndAnswer

java.lang.Object
  extended bytalx.games.tech.QuestionAndAnswer
All Implemented Interfaces:
java.io.Serializable

public class QuestionAndAnswer
extends java.lang.Object
implements java.io.Serializable

Holds a list of question and possibly an answer strings.

See Also:
Serialized Form

Constructor Summary
QuestionAndAnswer(java.lang.String question, QuestionAndAnswer previous)
          Creates a question with no answer.
QuestionAndAnswer(java.lang.String question, java.lang.String answer, QuestionAndAnswer previous)
          Creates a question and answer.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determines if two question and answer chains are equal.
 java.lang.String getAnswer()
          Returns the question encapsulated in this object.
 QuestionAndAnswer getNext()
          Returns the next object in the chain.
 java.lang.String getQuestion()
          Returns the question encapsulated in this object.
 boolean isAnswered()
          Determines if the question is answered.
 void setAnswer(java.lang.String answer)
          Sets the answer to this question.
 java.lang.String toString()
          Returns the string representation of the chain.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuestionAndAnswer

public QuestionAndAnswer(java.lang.String question,
                         QuestionAndAnswer previous)
Creates a question with no answer.

Parameters:
question - the question for this object.
previous - the object before this one in the chain, or null if this is the beginning of a new chain.
Throws:
java.lang.NullPointerException - if question is null.

QuestionAndAnswer

public QuestionAndAnswer(java.lang.String question,
                         java.lang.String answer,
                         QuestionAndAnswer previous)
Creates a question and answer. If answer is null, no exception is thrown, however, isAnswered will return false.

Parameters:
question - the question for this object, cannot be null.
answer - the answer for this object or null if this is unanswered.
previous - the object before this one in the chain or null if this is the beginning of a new chain.
Throws:
java.lang.NullPointerException - if question is null.
Method Detail

getQuestion

public java.lang.String getQuestion()
Returns the question encapsulated in this object.


getAnswer

public java.lang.String getAnswer()
Returns the question encapsulated in this object. If there is no answer, this method returns the empty string.


setAnswer

public void setAnswer(java.lang.String answer)
Sets the answer to this question.

Parameters:
answer - the text of the answer, or null if the question should be marked as unanswered.

isAnswered

public boolean isAnswered()
Determines if the question is answered.

Returns:
true if and only if the answer is non-empty

getNext

public QuestionAndAnswer getNext()
Returns the next object in the chain.


toString

public java.lang.String toString()
Returns the string representation of the chain.

Returns:
html marked up version of questions and answers from this object to the end of the chain.

equals

public boolean equals(java.lang.Object o)
Determines if two question and answer chains are equal.

Returns:
true if and only if o is a QuestionAndAnswer, with the same question text, same answer text, and same following chain as this.

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.