LectureGame.GameMode
Class MeasureUpMode

java.lang.Object
  extended by LectureGame.GameMode.MeasureUpMode
All Implemented Interfaces:
GameMode

public class MeasureUpMode
extends java.lang.Object
implements GameMode

Created by IntelliJ IDEA. User: olekrst Date: 22.feb.2007 Time: 16:25:20 This game mode is more a traditional "answer correctly and receive points" type of quiz. Partisipants logging in after the round has started can also partisipate. For method descriptions, see the GameMode interface

See Also:
GameMode

Field Summary
private  java.util.ArrayList<StudentClient> connections
           
private  Question currentQuestion
           
private  DataBaseConnection db
           
private  NetworkManager manager
           
private  int maxScorePerQuestion
           
private  NetworkConnectionKeeper netKeeper
           
private  int questionIndex
           
private  Question[] questionList
           
private  int questionState
           
private  int roundID
           
 
Constructor Summary
MeasureUpMode(NetworkConnectionKeeper netKeeper)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

private NetworkManager manager

currentQuestion

private Question currentQuestion

questionList

private Question[] questionList

db

private DataBaseConnection db

questionIndex

private int questionIndex

roundID

private int roundID

questionState

private int questionState

maxScorePerQuestion

private int maxScorePerQuestion

connections

private java.util.ArrayList<StudentClient> connections

netKeeper

private NetworkConnectionKeeper netKeeper
Constructor Detail

MeasureUpMode

public MeasureUpMode(NetworkConnectionKeeper netKeeper)
Method Detail

nextQuestion

public Question nextQuestion()
Description copied from interface: GameMode
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.

Specified by:
nextQuestion in interface GameMode
Returns:
the next question in the round
See Also:
Question

createMasterQuestion

public java.lang.String createMasterQuestion()
Description copied from interface: GameMode
Formats a question for sending to the master client.

Specified by:
createMasterQuestion in interface GameMode
Returns:
a string formatted and ready for sending to the master client

createClientQuestion

public java.lang.String createClientQuestion()
Description copied from interface: GameMode
Uses the current question in the round and formats it for sending to the student clients

Specified by:
createClientQuestion in interface GameMode
Returns:
correctly formatted string containing the question
See Also:
StudentClient, Question

initiateRound

public void initiateRound()
Description copied from interface: GameMode
Extracts all the questions from the current round from the database

Specified by:
initiateRound in interface GameMode
See Also:
DataBaseConnection

getMaxScore

public int getMaxScore()
Description copied from interface: GameMode
Returns the maximum possible score per question

Specified by:
getMaxScore in interface GameMode
Returns:
max score per question
See Also:
Question

handleClientQuestionReply

public java.lang.String handleClientQuestionReply(int score,
                                                  int roundScore,
                                                  int totalPossibleScore)
Description copied from interface: GameMode
Formats the results of the question answers from the studentclients

Specified by:
handleClientQuestionReply in interface GameMode
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

checkAns

public int checkAns(java.lang.String answer,
                    StudentClient c)
Description copied from interface: GameMode
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.

Specified by:
checkAns in interface GameMode
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)

getQuestionState

public int getQuestionState()
Description copied from interface: GameMode
Returns an integer referencing the question state in the LG constants class

Specified by:
getQuestionState in interface GameMode
Returns:
the question state
See Also:
LG

setQuestionState

public void setQuestionState(int s)
Description copied from interface: GameMode
Sets the state of the current question to the state given as an argument.

Specified by:
setQuestionState in interface GameMode
Parameters:
s - question state (see LG constants class)
See Also:
LG

handleQuestionReply

public java.lang.String handleQuestionReply()
Description copied from interface: GameMode
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.

Specified by:
handleQuestionReply in interface GameMode
Returns:
a string formatted for sending to the master client, containing the score of all the active student clients

handleEndOfRound

public java.lang.String handleEndOfRound()
Description copied from interface: GameMode
Formats an end of round string for sending to the masterclient

Specified by:
handleEndOfRound in interface GameMode
Returns:
a formatted string for sending to the master client