game

Class Move

Implemented Interfaces:
Comparable, Comparator, Transport

public class Move
extends java.lang.Object
implements Comparator, Transport, Comparable

This class encapsulates a move for the palyers.It has two data members,one for representing the node position and the other for representing the ticket Type for the move
Version:
2.4 (19-APR-2010)
Author:
Shashi Mittal

Fields inherited from interface game.Transport

BLACK, BUS, FERRY, INF, NONE, TAXI, UG

Constructor Summary

Move(String str)
This constructor initializes the fields using the string representation of the object of this class e.g.
Move(int n, int t)
This constructor initializes the data members of the Move

Method Summary

int
compare(Object o1, Object o2)
Compares two objects of this class and returns the score depending on the values given by the getScore() method
int
compareTo(Object o)
This method compares this object to another objects
boolean
equal(Move m1, Move m2)
Checks if two objects of this class have the same score
int
getNode()
This method is used to get the nodeIndex of this class
int
getScore()
This method returns the score for this object which is used in the equals(),compare() and compareTo() methods
int
getType()
This method returns the ticket type
String
toDisplayString()
This method returns the string representation of this move (which is subsequently displayed in the combo box).
String
toString()
This method gives a simple string representation of the objects of this class
String
toStringTicket()
This method returns the string representation of the ticket which contained in this object.

Constructor Details

Move

public Move(String str)
This constructor initializes the fields using the string representation of the object of this class e.g. the method toString() returns the string representation of objects of this class as, for example, 46(Taxi) here 46 is the node position and Taxi is the ticket type. This method takes this string as the input and then tokenizes it to get the fields.
Parameters:
str - the string representation of a Move object

Move

public Move(int n,
            int t)
This constructor initializes the data members of the Move
Parameters:
n - the node index
t - the ticket Type

Method Details

compare

public int compare(Object o1,
                   Object o2)
Compares two objects of this class and returns the score depending on the values given by the getScore() method
Parameters:
o1 - the first Move object
o2 - two second Move object
Returns:
positive if score of o1 is greater than o2 0 if the scores are equal a negative value otherwise

compareTo

public int compareTo(Object o)
This method compares this object to another objects
Parameters:
o - the object which is to be compared to this class
Returns:
same as that given by int compare(Object o1,Object o2)

equal

public boolean equal(Move m1,
                     Move m2)
Checks if two objects of this class have the same score
Parameters:
m1 - the first Move object
m2 - the second Move object
Returns:
true if the scores are equal,false otherwise

getNode

public int getNode()
This method is used to get the nodeIndex of this class
Returns:
the node of the object

getScore

public int getScore()
This method returns the score for this object which is used in the equals(),compare() and compareTo() methods
Returns:
the score for this Move

getType

public int getType()
This method returns the ticket type
Returns:
the ticket type in the object

toDisplayString

public String toDisplayString()
This method returns the string representation of this move (which is subsequently displayed in the combo box).
Returns:
the string representation of the current move using the current locale

toString

public String toString()
This method gives a simple string representation of the objects of this class
Returns:
the string representation of object of this class

toStringTicket

public String toStringTicket()
This method returns the string representation of the ticket which contained in this object.
Returns:
the String representation of the ticket type of this class