LectureGame.Core
Class Question

java.lang.Object
  extended by LectureGame.Core.Question

public class Question
extends java.lang.Object

Created by IntelliJ IDEA. User: olekrst Date: 26.jan.2007 Time: 16:40:05 This class is a generalization of a question, as used in the LectureGame.Core.LG


Field Summary
private  java.lang.String[] alternatives
           
private  java.lang.String correctAlternative
           
private  java.lang.String formattedQuestion
           
private  int numberOfAlt
           
private  java.lang.String question
           
private  java.lang.String timeLimit
           
 
Constructor Summary
Question(java.lang.String question, int numberOfAlt, java.lang.String[] alternatives, java.lang.String timeLimit, java.lang.String correctAlternative)
           
 
Method Summary
 java.lang.String getCorrectAnswer()
          Returns the correct alternative, an index of the String array as entered when creating the question
 int getTimeLimit()
          Returns the timelimit of the question
 java.lang.String makeClientQuestion(int questionState)
          Creates the question to be sendt to the StudentClient.
 java.lang.String makeMasterQuestion(int questionState)
          Creates the question to be sendt to the MasterClient.
private  java.lang.String makeQuestionRoot()
          Creates the root of the question to be sendt to eighter the studenclients or the masterclient.
 void testQuestion()
          This method is used for testing purposes. prints the question to console.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

question

private java.lang.String question

numberOfAlt

private int numberOfAlt

alternatives

private java.lang.String[] alternatives

timeLimit

private java.lang.String timeLimit

correctAlternative

private java.lang.String correctAlternative

formattedQuestion

private java.lang.String formattedQuestion
Constructor Detail

Question

public Question(java.lang.String question,
                int numberOfAlt,
                java.lang.String[] alternatives,
                java.lang.String timeLimit,
                java.lang.String correctAlternative)
Parameters:
question - Question text. example "who am i?"
numberOfAlt - number of answers to choose from
alternatives - Array of alternatives. example {"me","you","them"}
timeLimit - time given to reply to the question. 0 = the server decides
correctAlternative - index number of the alternative in the Array of alternatives that is correct. Can only be one
Method Detail

makeQuestionRoot

private java.lang.String makeQuestionRoot()
Creates the root of the question to be sendt to eighter the studenclients or the masterclient. The root is similar, thus this only needs one method. The last part of the question is different though. Example of output:

Returns:
a question root

testQuestion

public void testQuestion()
This method is used for testing purposes. prints the question to console.


getCorrectAnswer

public java.lang.String getCorrectAnswer()
Returns the correct alternative, an index of the String array as entered when creating the question

Returns:
the correct alternative (formatted as String since it is to be sendt to the clients)

getTimeLimit

public int getTimeLimit()
Returns the timelimit of the question

Returns:
timelimit

makeClientQuestion

public java.lang.String makeClientQuestion(int questionState)
Creates the question to be sendt to the StudentClient. Appends: 0 - not last question in lecture 1 - last question in round 2 - last question i lecture

Parameters:
questionState - the state of the question
Returns:
String formatted and ready to be sendt to the StudentClient

makeMasterQuestion

public java.lang.String makeMasterQuestion(int questionState)
Creates the question to be sendt to the MasterClient. Appends first the correct alternative (which is not sendt to the clients) and then appends: 0 - not last question in lecture 1 - last question in round 2 - last question i lecture

Parameters:
questionState - the state of the question
Returns:
String formatted and ready to be sendt to the StudentClient