package output; import game.Config; public class HistoryFileWriter { private final static String playersPath = Config.getBlackBoardPath() + "/history.xml"; //address of history xml file private static HistoryFileWriter reference; //reference to StoreFileWriter singleton /** * default constructor */ private HistoryFileWriter() //private local constructor { reference = null; } /** * Initialize a new PlayersFileWriter if one does not exist * @return PlayersFileWriter */ public static HistoryFileWriter initialize() { if( reference == null ) //if a write does not exist return new HistoryFileWriter(); //return new writer else //otherwise return reference; //return existing writer } /** * get the PlayersFileWriter * * @return PlayersFileWriter */ public static HistoryFileWriter getPlayersFileWriter() { return reference; } /** * write the text to the players file * * @param pText : text to be written */ public void writeFile( String pText ) { XMLFileWriter writer = XMLFileWriter.initialize(); //get an XMLFileWriter writer.writeFile( playersPath, pText ); //write the document } }