Package tk.dmanstrator.connectfour.log
Class GameLogEntry
- java.lang.Object
-
- tk.dmanstrator.connectfour.log.GameLogEntry
-
public class GameLogEntry extends java.lang.Object
Class representing an entry for theGameLog
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GameLogEntry.RoundTitle
Represents the title of a round.
-
Constructor Summary
Constructors Constructor Description GameLogEntry(java.lang.String message, int roundNumber, int playerNumber, boolean validRound, GameLogEntry.RoundTitle title)
Constructor for the entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAsString()
Gets the entry as a string.java.lang.String
getMessage()
Returns the message of the entry.int
getPlayerNumber()
Returns the player number of the entry.int
getRoundNumber()
Returns the round number of the entry.GameLogEntry.RoundTitle
getRoundTitle()
Returns theGameLogEntry.RoundTitle
of the entry.boolean
isValidRound()
Returns flag telling if it was a valid round.java.lang.String
toString()
Returns the entry as a string.
-
-
-
Constructor Detail
-
GameLogEntry
public GameLogEntry(java.lang.String message, int roundNumber, int playerNumber, boolean validRound, GameLogEntry.RoundTitle title)
Constructor for the entry.- Parameters:
message
- Message of the entryroundNumber
- Round number of the entryplayerNumber
- Player number of the entryvalidRound
- Flag telling if it was a valid roundtitle
-GameLogEntry.RoundTitle
of the entry
-
-
Method Detail
-
getMessage
public java.lang.String getMessage()
Returns the message of the entry.- Returns:
- The message of the entry
-
getRoundNumber
public int getRoundNumber()
Returns the round number of the entry. Will be-1
if round was invalid.- Returns:
- The round number of the entry
-
getPlayerNumber
public int getPlayerNumber()
Returns the player number of the entry. Will be0
if no player was passed.- Returns:
- The player number of the entry
-
isValidRound
public boolean isValidRound()
Returns flag telling if it was a valid round.- Returns:
true
if round was valid, elsefalse
-
getRoundTitle
public GameLogEntry.RoundTitle getRoundTitle()
Returns theGameLogEntry.RoundTitle
of the entry.- Returns:
- The
GameLogEntry.RoundTitle
of the entry
-
getAsString
public java.lang.String getAsString()
Gets the entry as a string. Adds the round number into theGameLogEntry.RoundTitle
when it's a valid round. Converts the player number to[Player X]
if a player number was set.- Returns:
- The entry as a string in format
<Title> [Player]: <Message>
-
toString
public java.lang.String toString()
Returns the entry as a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The entry as a string
- See Also:
getAsString()
-
-