game
Class Move
- Comparable, Comparator, Transport
public class Move
extends java.lang.Object
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
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
|
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.
|
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.
str
- the string representation of a Move object
Move
public Move(int n,
int t)
This constructor initializes the data members of the Move
n
- the node indext
- the ticket Type
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
o1
- the first Move objecto2
- two second Move object
- 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
o
- the object which is to be compared to this class
- 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
m1
- the first Move objectm2
- the second Move object
- true if the scores are equal,false otherwise
getNode
public int getNode()
This method is used to get the nodeIndex of this class
getScore
public int getScore()
This method returns the score for this object which is used in the
equals(),compare() and compareTo() methods
getType
public int getType()
This method returns the ticket type
- 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).
- 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
- 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.
- the String representation of the ticket type of this class