vooga.examples.networking.tictactoe
Class Move

java.lang.Object
  extended by vooga.examples.networking.tictactoe.Move
All Implemented Interfaces:
Serializeable

public class Move
extends java.lang.Object
implements Serializeable

Move is a simple example of how to use the Serializable interface. If you want to send a piece of data then wrap a class around that data and have it implements the Serializable interface to be able to send it over the network. In TicTacToe, the only piece of data we send besides status updates are moves. The Move class wraps the column and row that make up a move and has serialize and deserialize methods that convert the Move into a String to send over the network and convert the String into a Move to receive from the network.


Constructor Summary
Move(int row, int col)
          Constructor that saves the row and column.
 
Method Summary
static Serializeable deserialize(java.lang.String data)
          Takes a String and parses the column and row from the string and returns a new Move object from that row and column.
 int getCol()
           
 int getRow()
           
 java.lang.String serialize()
          Takes the row number and the column number and returns the String that represents that move.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Move

public Move(int row,
            int col)
Constructor that saves the row and column.

Parameters:
row - the row
col - the column
Method Detail

deserialize

public static Serializeable deserialize(java.lang.String data)
Takes a String and parses the column and row from the string and returns a new Move object from that row and column.

Parameters:
data - the String representing a Move object
Returns:
a new Move object based on the data in the data param

serialize

public java.lang.String serialize()
Takes the row number and the column number and returns the String that represents that move.

Specified by:
serialize in interface Serializeable
Returns:
String to send to the socket that represents the Move

getRow

public int getRow()
Returns:
the row of the move

getCol

public int getCol()
Returns:
the column of the move