package gomoku;
import java.util.List;
import java.util.ArrayList;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Record every play into file
 * @author LongYang
 *
 */
public class GameData {
	private List<int[][]> list;
	private int result;
	public GameData(){
		list = new ArrayList<int[][]>();
	}
	public GameData(List<int[][]> list){
		this.list = list;
	}
	public void append(ChessBoard chessboard){
		list.add(chessboard.ChessBoardInfo());
	}
	public void GameEnd(int status){
		this.result = status;
	}
	public List<int[][]> getdata(){
		return this.list;
	}
	public int getresult(){
		return this.result;
	}
	
	/**
	 * Get Game Data from file
	 * @param filename File name
	 * @return GameData Game Data
	 * @throws IOException
	 */
	public GameData load(String filename) throws IOException{
		
		return new GameData();
	}
	
	/**
	 * Save Game Data into files
	 * 
	 * @param filename File Name
	 * @throws IOException
	 */
	public void save(String filename) throws IOException{
		FileWriter fw = null;
		BufferedWriter bw = null;
		fw = new FileWriter("./data/"+filename,true);
		bw = new BufferedWriter(fw,100);
		// TODO Write Data
		bw.flush();
		bw.close();
		fw.close();
	}
}

@@ -138,27 +138,149 @@
 java.io.
-IOException
+FileReader;%0D%0Aimport java.io.BufferedReader;%0D%0Aimport java.io.IOException;%0D%0A%0D%0Aimport java.util.Date;%0D%0Aimport java.text.SimpleDateFormat
 ;%0D%0A%0D%0A/**
@@ -426,65 +426,355 @@
 %0D%0A%09p
-ublic GameData()%7B%0D%0A%09%09list = new ArrayList%3Cint%5B%5D%5B%5D%3E();%0D%0A%09%7D
+rivate String name;%0D%0A%09%0D%0A%09/**%0D%0A%09 * Default generation of Game Data%0D%0A%09 */%0D%0A%09public GameData()%7B%0D%0A%09%09SimpleDateFormat df = new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22);%0D%0A%09%09this.name = df.format(new Date());%0D%0A%09%09this.list = new ArrayList%3Cint%5B%5D%5B%5D%3E();%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * Generation of Game Data%0D%0A%09 * @param name Game Data Name%0D%0A%09 * @param list Data List%0D%0A%09 */
 %0D%0A%09p
@@ -788,16 +788,29 @@
 ameData(
+String name, 
 List%3Cint
@@ -819,24 +819,45 @@
 %5B%5D%3E list)%7B%0D%0A
+%09%09this.name = name;%0D%0A
 %09%09this.list 
@@ -861,32 +861,35 @@
 st = list;%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public void app
@@ -959,24 +959,27 @@
 fo());%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public void
@@ -1026,24 +1026,27 @@
 tatus;%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public List
@@ -1092,16 +1092,19 @@
 t;%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public 
@@ -1280,32 +1280,39 @@
 %0D%0A%09 */%0D%0A%09public 
+static 
 GameData load(St
@@ -1349,16 +1349,197 @@
 ion%7B%0D%0A%09%09
+FileReader fr = null;%0D%0A%09%09BufferedReader br = null;%0D%0A%09%09fr = new FileReader(%22./data/%22+filename);%0D%0A%09%09br = new BufferedReader(fr,100);%0D%0A%09%09// TODO Read Data%0D%0A%09%09br.close();%0D%0A%09%09fr.close();
 %0D%0A%09%09retu

Update GameData