|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.examples.networking.tictactoe.Move
public class Move
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 |
---|
public Move(int row, int col)
row
- the rowcol
- the columnMethod Detail |
---|
public static Serializeable deserialize(java.lang.String data)
data
- the String representing a Move object
public java.lang.String serialize()
serialize
in interface Serializeable
public int getRow()
public int getCol()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |