Java swing读取读取txt文件实现学生考试系统文件实现学生考试系统
主要为大家详细介绍了Java swing读取txt文件实现学生考试系统,文中示例代码介绍的非常详细,具有一定的
参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了Java swing读取txt文件实现学生考试系统的具体代码,供大家参考,具体内容如下
主要实现了一个简单的倒计时答题系统
源码Testquestion 类
public class Testquestion {
private String questionText ="";//定义题目
private String standardkey = "";// 定义正确答案
private String selectKey ="";// 定义输入答案
public Testquestion(String questionText, String standardkey) {
super();
this.questionText = questionText;
this.standardkey = standardkey;
}
public String getQuestionText() {
return questionText;
}
public void setQuestionText(String questionText) {
this.questionText = questionText;
}
public String getStandardkey() {
return standardkey;
}
public void setStandardkey(String standardkey) {
this.standardkey = standardkey;
}
public String getSelectKey() {
return selectKey;
}
public void setSelectKey(String selectKey) {
this.selectKey = selectKey;
}
public boolean check() {
if (this.selectKey.equals(this.standardkey)) {
return true;
}
else {
return false;
}
}
}
主程序Test2
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.NumberFormat;
import java.util.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Test2 extends JFrame implements ActionListener{
private JButton start,commit,back,next;
private JRadioButton aButton,bButton,cButton,dButton;
private ButtonGroup buttonGroup;
private JLabel label,clock;
private JTextArea jTextArea;
private JPanel panel,panel2,panel3;
Testquestion t1;
Testquestion[] questions;
int examtime;
int p=0;//设置题目数指针
int topicnum=0;
int right,error; //答对和答错
ClockDispaly mt; //倒计时模块
public Test2(){
this.setTitle("学生在线考试系统v1"); //设置标题
this.setSize(440,320); //设置窗口大小