LectureGame.GameMode
Interface GameMode

All Known Implementing Classes:
EliminationMode, MeasureUpMode

public interface GameMode

Created by IntelliJ IDEA. User: olekrst Date: 22.feb.2007 Time: 13:19:13 Interface used to dynamically swap the gameMode. All GameModes must implement this interface.


Method Summary
 int checkAns(java.lang.String answer, StudentClient c)
          Checks the answer from the studentclients and returns an int depending on what is expected from the gamemode.
 java.lang.String createClientQuestion()
          Uses the current question in the round and formats it for sending to the student clients
 java.lang.String createMasterQuestion()
          Formats a question for sending to the master client.
 int getMaxScore()
          Returns the maximum possible score per question
 int getQuestionState()
          Returns an integer referencing the question state in the LG constants class
 java.lang.String handleClientQuestionReply(int score, int roundScore, int totalPossibleScore)
          Formats the results of the question answers from the studentclients
 java.lang.String handleEndOfRound()
          Formats an end of round string for sending to the masterclient
 java.lang.String handleQuestionReply()
          Method for creating the reply string which is sendt to the masterclient.
 void initiateRound()
          Extracts all the questions from the current round from the database
 Question nextQuestion()
          Iterates to the the next question in the round.
 void setQuestionState(int s)
          Sets the state of the current question to the state given as an argument.
 

Method Detail

handleQuestionReply

java.lang.String handleQuestionReply()
Method for creating the reply string which is sendt to the masterclient. This string contains the score of all active student clients, and is sendt from the server after each question has timed out.

Returns:
a string formatted for sending to the master client, containing the score of all the active student clients

handleEndOfRound

java.lang.String handleEndOfRound()
Formats an end of round string for sending to the masterclient

Returns:
a formatted string for sending to the master client

nextQuestion

Question nextQuestion()
Iterates to the the next question in the round. Sets the questionstate according to whether or not the question is the last one in the lecture.

Returns:
the next question in the round
See Also:
Question

createMasterQuestion

java.lang.String createMasterQuestion()
Formats a question for sending to the master client.

Returns:
a string formatted and ready for sending to the master client

getQuestionState

int getQuestionState()
Returns an integer referencing the question state in the LG constants class

Returns:
the question state
See Also:
LG

setQuestionState

void setQuestionState(int s)
Sets the state of the current question to the state given as an argument.

Parameters:
s - question state (see LG constants class)
See Also:
LG

createClientQuestion

java.lang.String createClientQuestion()
Uses the current question in the round and formats it for sending to the student clients

Returns:
correctly formatted string containing the question
See Also:
StudentClient, Question

initiateRound

void initiateRound()
Extracts all the questions from the current round from the database

See Also:
DataBaseConnection

handleClientQuestionReply

java.lang.String handleClientQuestionReply(int score,
                                           int roundScore,
                                           int totalPossibleScore)
Formats the results of the question answers from the studentclients

Parameters:
score - the score received from answering the last question
roundScore - total score in the current round
totalPossibleScore - overall score
Returns:
a sting correctly formatted for sending to the student clients

getMaxScore

int getMaxScore()
Returns the maximum possible score per question

Returns:
max score per question
See Also:
Question

checkAns

int checkAns(java.lang.String answer,
             StudentClient c)
Checks the answer from the studentclients and returns an int depending on what is expected from the gamemode. Typically this method will return 1 for correct and 0 for false.

Parameters:
answer - the answer index represented by a string
c - the client which replied
Returns:
an integer (typically 1 for correct, and 0 for false)