thinkAlike
Class ThinkRequest

java.lang.Object
  extended by thinkAlike.ThinkRequest

public class ThinkRequest
extends java.lang.Object

This class represents a session of the game ThinkAlike, it is created when a user wants to start a session, and when a user recieves a challange.


Constructor Summary
ThinkRequest(ProgramControl pc, java.lang.String to, java.lang.String from, java.lang.String pic, java.lang.String thinkword)
          Creates a new instance of ThinkRequest
 
Method Summary
 java.lang.String calculateResult()
          Simply checks if one of the three suggested word of the recipient matches the initial word and returns a string matching the result.
 void confirmRequest()
          This method is called when the a ThinkRequest is recieved, showing a screen asking the user to confirm if he want the session or not.
 java.lang.String getFrom()
          Returns the the address of the initiator fo the session
 java.lang.String getPic()
          Returns the the picture assosiated with this session, as a text string in Base64 encoding
 java.lang.String getThinkWord()
          Returns the the word that the initiator assosiated with the picture
 java.lang.String getTo()
          Returns the the address of the recipient fo the session
 java.lang.String getWord1()
          Return the first word suggested by the recipient
 java.lang.String getWord2()
          Return the second word suggested by the recipient
 java.lang.String getWord3()
          Return the third word suggested by the recipient
 boolean isInitiator()
          Returns if this ThinkRequest object is acting as an initiator or not
 void isInitiator(boolean is)
          Sets if this ThinkRequest object conatins the initiator or not (the other option is obviously the recipient)
 void makeEndForm()
          On both part of the session this method generates the end form where the participans also can chat.
 void makeResultForm()
          The session at the recipient, this method generates the form that show the result of her guessing.
 void recievedResponse(java.lang.String word1, java.lang.String word2, java.lang.String word3)
          When recieveing an answer to the challenge, this message get the three words suggested and puts them on the screen of the initiator.
 void requestConfirmed()
          deprecated
 void sendThinkRequest()
          Sends the actual request using the Jxa object.
 void sendWords()
          Used by the recipient to send the reply of the ThinkRequest to the initiator, using the Jxa object to send the three words.
 void setWords(java.lang.String word1, java.lang.String word2, java.lang.String word3)
          Simple method to set the three words suggested by the recipient
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThinkRequest

public ThinkRequest(ProgramControl pc,
                    java.lang.String to,
                    java.lang.String from,
                    java.lang.String pic,
                    java.lang.String thinkword)
Creates a new instance of ThinkRequest

Parameters:
pc - pointer to the ProgramControl class
to - the address of the recipient of the initial session
from - the address of the initiator of the session
pic - a text representation of the picture, encoded in Base64
thinkword - the word the initator assosiates with the picture
Method Detail

confirmRequest

public void confirmRequest()
This method is called when the a ThinkRequest is recieved, showing a screen asking the user to confirm if he want the session or not.


requestConfirmed

public void requestConfirmed()
deprecated


sendThinkRequest

public void sendThinkRequest()
                      throws java.io.IOException
Sends the actual request using the Jxa object. It does not send the object itself, but the picture and the thinkword to the recipient.

Throws:
java.io.IOException - On communication errors from the Jxa object.

recievedResponse

public void recievedResponse(java.lang.String word1,
                             java.lang.String word2,
                             java.lang.String word3)
When recieveing an answer to the challenge, this message get the three words suggested and puts them on the screen of the initiator. It also uses the calculateResult() to figure out if the recipient though of the same word.

Parameters:
word1 - first word
word2 - second word
word3 - third word

makeResultForm

public void makeResultForm()
The session at the recipient, this method generates the form that show the result of her guessing.


makeEndForm

public void makeEndForm()
On both part of the session this method generates the end form where the participans also can chat.


calculateResult

public java.lang.String calculateResult()
Simply checks if one of the three suggested word of the recipient matches the initial word and returns a string matching the result.

Returns:
a string that describes the outcome of the check

sendWords

public void sendWords()
               throws java.io.IOException
Used by the recipient to send the reply of the ThinkRequest to the initiator, using the Jxa object to send the three words. Notice that the response is sent back to the requester, therefore the to field of the message is the from variable in the ThinkRequest calss.

Throws:
java.io.IOException - in case of communication error when using the Jxa object

isInitiator

public void isInitiator(boolean is)
Sets if this ThinkRequest object conatins the initiator or not (the other option is obviously the recipient)

Parameters:
is - is true if it is the initiator

isInitiator

public boolean isInitiator()
Returns if this ThinkRequest object is acting as an initiator or not

Returns:
true if object is initiator, false if recipient

setWords

public void setWords(java.lang.String word1,
                     java.lang.String word2,
                     java.lang.String word3)
Simple method to set the three words suggested by the recipient

Parameters:
word1 - first word
word2 - second word
word3 - third word

getTo

public java.lang.String getTo()
Returns the the address of the recipient fo the session

Returns:
address of recipient

getFrom

public java.lang.String getFrom()
Returns the the address of the initiator fo the session

Returns:
address of initiator

getPic

public java.lang.String getPic()
Returns the the picture assosiated with this session, as a text string in Base64 encoding

Returns:
picture as text string

getThinkWord

public java.lang.String getThinkWord()
Returns the the word that the initiator assosiated with the picture

Returns:
TheWord

getWord1

public java.lang.String getWord1()
Return the first word suggested by the recipient

Returns:
first word

getWord2

public java.lang.String getWord2()
Return the second word suggested by the recipient

Returns:
second word

getWord3

public java.lang.String getWord3()
Return the third word suggested by the recipient

Returns:
third word