https://git.coding.net/Boxer_/homework.git
ssh:git@git.coding.net:Boxer_/homework.git
小组名称:新蜂
组长:武志远
组成员:宫成荣 谢孝淼 杨柳 李峤
项目名称:Java俄罗斯方块
站会时间:11.8
总任务:
1,数据库显示模块。
2,本地记录模块,
3,俄罗斯方块主模块
4,按钮窗口模块
5,下一个窗口模块
6,等级窗口模块,
7,分数窗口模块。
8,版权信息模块。
每日任务:
实现俄罗斯方块游戏的排行榜。
难点:界面好不够好看。
已完成:已经实现基本功能。
下面是部分硬盘存储代码:
public class DataDisk implements Datas { private final String fillPath; public DataDisk(HashMap<String, String> param) { fillPath=param.get("path"); } @SuppressWarnings("unchecked") @Override public List<Player> loadData() { ObjectInputStream ois = null; List<Player> players = null; try { ois = new ObjectInputStream(new FileInputStream(fillPath)); players = (List<Player>) ois.readObject(); } catch (Exception e) { e.printStackTrace(); } finally { try { ois.close(); } catch (IOException e) { e.printStackTrace(); } } return players; }
存储数据的方法:
public void saveData(Player play) { // 先读出本地记录 List<Player> players = this.loadData(); // 然后追加 players.add(play); //只要记录高的前五名,其他的都不要 Collections.sort(players); for (int i =5; i < players.size(); i++) { players.remove(i); } // 最后写到本机磁盘 ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream(fillPath)); oos.writeObject(players); } catch (IOException e) { e.printStackTrace(); } finally { try { oos.close(); } catch (IOException e) { e.printStackTrace(); } }