src/main/java/tsz/game/DAO/GameDataDAO.java
/**
	 * Write the gameplay data .
	 * @param gamedata - the last gameplay data to be stored.
	 */
Write the gameplay data .
@param gamedata - the last gameplay data to be stored.
Write the gameplay data . @param gamedata - the last gameplay data to be stored .
@SuppressWarnings("unchecked")
	public void saveGameData(GameData gamedata) {
		ObjectMapper mapper = new ObjectMapper();
		JSONParser parser = new JSONParser();
		try {
				File dataFile = new File(this.pathToDataFile);
				InputStream input = new FileInputStream(dataFile);
				Reader reader = new InputStreamReader(input);
				jsonArray = (JSONArray) parser.parse(reader);
				String jsonInString = mapper.writeValueAsString(gamedata);
				jsonArray.add(jsonInString);
				PrintWriter printWriter = new PrintWriter(dataFile);
				printWriter.write(jsonArray.toJSONString());
				printWriter.close();
			logger.info("Game Data saved.");
		} catch (IOException | ParseException e) {
			logger.error(e.toString());
		}		
	}
@ SuppressWarnings ( "unchecked" ) public void saveGameData ( GameData gamedata ) { ObjectMapper mapper = new ObjectMapper ( ) ; JSONParser parser = new JSONParser ( ) ; try { File dataFile = new File ( this . pathToDataFile ) ; InputStream input = new FileInputStream ( dataFile ) ; Reader reader = new InputStreamReader ( input ) ; jsonArray = ( JSONArray ) parser . parse ( reader ) ; String jsonInString = mapper . writeValueAsString ( gamedata ) ; jsonArray . add ( jsonInString ) ; PrintWriter printWriter = new PrintWriter ( dataFile ) ; printWriter . write ( jsonArray . toJSONString ( ) ) ; printWriter . close ( ) ; logger . info ( "Game Data saved." ) ; } catch ( IOException | ParseException e ) { logger . error ( e . toString ( ) ) ; } }
Write the gameplay data .
Write the gameplay data .