Package hoverball
Class Puck
java.lang.Object
hoverball.Puck
public class Puck
extends java.lang.Object
The class Puck memorizes all information about a puck that can be perceived or
deduced by a unit.
This can be:
- object identity composed of the identification
(what t n)
, - object message, if the object is a unit,
- position and looking direction in the form of a orthonormal matrix,
- radius,
- mass.
With the class Puck you have at your disposal various methods that allow to organize and compare objects.
-
Field Summary
Fields Modifier and Type Field Description static int
BALL
type constant: balljava.lang.String
id
object identity (as string)double
m
object massjava.lang.String
message
object message (if unit)int
n
object puck number (= player number if unit)static int
NODE
type constant: nodedouble
r
object radiusint
t
object team numberstatic int
UNIT
type constant: unitint
what
object typeMatrix
X
object position (as orthonormal matrix) -
Constructor Summary
Constructors Constructor Description Puck(int what, int t, int n)
Creates a puck with the specified identity, all other values are null.Puck(int what, int t, int n, Matrix X, double r, double m, java.lang.String message)
Creates a puck with the specified values.Puck(Puck puck)
Creates a puck equal to another. -
Method Summary
Modifier and Type Method Description boolean
equals(int what)
Compares the type.boolean
equals(int what, int t)
Compares type and team.boolean
equals(int what, int t, int n)
Compares the identity.boolean
equals(java.lang.Object puck)
Compares with a puck.boolean
equals(java.lang.String id)
Compares the identity (as string).int
hashCode()
Returns the hash code.static java.lang.String
id(int what, int t, int n)
Creates the identity (as string).java.lang.String
toString()
string representation.
-
Field Details
-
NODE
public static final int NODEtype constant: node- See Also:
- Constant Field Values
-
BALL
public static final int BALLtype constant: ball- See Also:
- Constant Field Values
-
UNIT
public static final int UNITtype constant: unit- See Also:
- Constant Field Values
-
id
public final java.lang.String idobject identity (as string) -
what
public final int whatobject type -
t
public final int tobject team number -
n
public final int nobject puck number (= player number if unit) -
r
public final double robject radius -
m
public final double mobject mass -
X
object position (as orthonormal matrix) -
message
public java.lang.String messageobject message (if unit)
-
-
Constructor Details
-
Puck
Creates a puck equal to another.- Parameters:
puck
- copied puck
-
Puck
public Puck(int what, int t, int n)Creates a puck with the specified identity, all other values are null.- Parameters:
what
- object typet
- team numbern
- puck number
-
Puck
Creates a puck with the specified values.- Parameters:
what
- object typet
- team numbern
- puck numberX
- orientierted positionr
- radiusm
- massmessage
- message
-
-
Method Details
-
id
public static java.lang.String id(int what, int t, int n)Creates the identity (as string).- Parameters:
what
- object typet
- team numbern
- puck number- Returns:
- the identity
-
equals
public boolean equals(java.lang.Object puck)Compares with a puck.Two puck objects are equal iff their identities are equal.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
puck
- puck- Returns:
- the equality
-
equals
public boolean equals(int what)Compares the type.- Parameters:
what
- object type- Returns:
- the equality
-
equals
public boolean equals(int what, int t)Compares type and team.- Parameters:
what
- object typet
- team number- Returns:
- the equality
-
equals
public boolean equals(int what, int t, int n)Compares the identity.- Parameters:
what
- object typet
- team numbern
- puck number- Returns:
- the equality
-
equals
public boolean equals(java.lang.String id)Compares the identity (as string).- Parameters:
id
- identity string- Returns:
- the equality
-
hashCode
public int hashCode()Returns the hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code
-
toString
public java.lang.String toString()string representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string
-