Package pacman.util
Class ScoreBoardWriter
- java.lang.Object
-
- pacman.util.ScoreBoardWriter
-
public class ScoreBoardWriter extends java.lang.Object
ScoreBoardWriter
A
ScoreBoardWriter
is an object of utility to write aScore
to a score board file.Usage:
ScoreBoardWriter scoreBoardWriter = new ScoreBoardWriter(fileName); scoreBoardWriter.write(score);
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Song Zhang
- See Also:
ScoreBoardReader
,ScoreBoard
,Score
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
path
The path of the score board file.
-
Constructor Summary
Constructors Constructor Description ScoreBoardWriter(java.lang.String fileName)
Allocates a newScoreBoardWriter
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
convertToByteString(Score object)
Converts a aScore
object to a byte string and returns it.private void
init()
Initializes the file if it doesn't exist.void
write(Score score)
Writes the givenScore
to the score board file.private void
writeNewLine(java.lang.String line)
Writes a new line to the file.
-
-
-
Constructor Detail
-
ScoreBoardWriter
public ScoreBoardWriter(java.lang.String fileName)
Allocates a newScoreBoardWriter
.- Parameters:
fileName
- the file name of the score board file to be written
-
-
Method Detail
-
convertToByteString
private static java.lang.String convertToByteString(Score object) throws java.lang.Exception
Converts a aScore
object to a byte string and returns it.
-
writeNewLine
private void writeNewLine(java.lang.String line)
Writes a new line to the file.- Parameters:
line
- a string line to be written.
-
init
private void init()
Initializes the file if it doesn't exist.
-
-