【第七周】【新蜂站会】2

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();
            }
        }

 

 

转载于:https://www.cnblogs.com/Boxer1994/p/6045071.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值