public class Score extends java.lang.Object implements java.lang.Comparable<Score>, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
int |
score
the socre
|
java.lang.String |
username
the username
|
| Constructor and Description |
|---|
Score(java.lang.String username,
int score)
Initiates the score with name and score
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Score o)
Compares the current score and another score.
|
static Score |
fromString(java.lang.String serialized)
Convert from the string representation of the score into the Score data object.
|
java.lang.String |
toString()
Serializes the score data object into a string.
|
public final java.lang.String username
public final int score
public Score(java.lang.String username,
int score)
username - the username of the playerscore - the score of the playerpublic static Score fromString(java.lang.String serialized) throws java.lang.NumberFormatException
serialized - string version of the scorejava.lang.NumberFormatException - thrown when the score is invalidpublic java.lang.String toString()
The string format is: username and newline separated by a newline character (\n)
toString in class java.lang.Object