西北工业大学#面向对象编程实验#实验四->第二题

题目二:GUI界面编程

额,怎么说呢,题目二涉及到GUI的东西异常的少,,只要求补全两个class的代码,其余的能看懂就可以做题

DisplayExamPaperListener

这个class几乎用不到,,,,

public void actionPerformed(ActionEvent event) {
            if(studentCatalog.getNumberOfStudents ()==0){
                statusTextArea.setText ("The catalog of students is empty.");
            }else{
                statusTextArea.setText(studentsFormatter.formatStudents(studentCatalog));
            }
        }

class SaveExamPaperListener

JFileChooser jFileChooser = new JFileChooser();
            BufferedWriter bw=null;
            if (0 == jFileChooser.showSaveDialog(null)) {
                File saveFile = jFileChooser.getSelectedFile();
                try {
                    if (!saveFile.exists()) {
                        saveFile.createNewFile();
                    }
                    bw = new BufferedWriter(new FileWriter(saveFile));
                    bw.write(studentsFormatter.formatStudents(studentCatalog));
                }
                catch (IOException e) {
                    e.printStackTrace();
                }finally {
                    try {
                        bw.close ();
                    } catch (IOException e) {
                        e.printStackTrace ();
                    }
                }
            }

注意!!!

当补全以上两个class的内容时,代码并不能正常运行,尤其是当展示试卷的时候,因为我在之前Plain,
、XML和HTML单例模式输出studentcatalog时,没有考虑未生成试卷的情况,而这次的题目会出现有些student的exmepaper未生成的情况,因此记得加上判断条件,不然会报错。

  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值