Package pacman.util
Class ScoreBoardWriter
- java.lang.Object
-
- pacman.util.ScoreBoardWriter
-
public class ScoreBoardWriter extends java.lang.ObjectScoreBoardWriter
A
ScoreBoardWriteris an object of utility to write aScoreto 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.StringpathThe 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.StringconvertToByteString(Score object)Converts a aScoreobject to a byte string and returns it.private voidinit()Initializes the file if it doesn't exist.voidwrite(Score score)Writes the givenScoreto the score board file.private voidwriteNewLine(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 aScoreobject 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.
-
-