当前位置:文档之家› java学生考试管理系统

java学生考试管理系统

} }
} import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class EnglishTest extends JFrame {
TestArea testPanel=null; Container con=null; public EnglishTest() {
Container cp=getContentPane(); cp.setLayout(new GridLayout(4,1)); Label l1=new Label("用户名"); Label l2=new Label("密 码"); Panel p1=new Panel(); Panel p2=new Panel(); Panel p3=new Panel(); f1=new TextField(10); f2=new TextField(10); f2.setEchoChar('*'); b1=new JButton("登录"); b2=new JButton("重置"); b3=new JButton("退出"); p1.add(l1); p1.add(f1); p2.add(l2); p2.add(f2); p3.add(b1); p3.add(b2);
} catch(Exception e)
{ testContent="没有选择试题";
} } public String getFilename() {
return filename; } publtime; } public void set 完成考试(boolean b) {
完成考试=b; } public boolean get 完成考试() {
return 完成考试; } public String getTestContent()
{ try { String s=null; StringBuffer temp=new StringBuffer();
if(读取!=null) { while((s=读取.readLine())!=null) { if(s.startsWith("**")) break; temp.append("\n"+s); if(s.startsWith("endend")) { in.close(); 读取.close(); 完成考试=true; } } testContent=new String(temp); }
{ try{ if(selection.charAt(i)==correctAnswer.charAt(i)) score++; }
catch(StringIndexOutOfBoundsException e) { i=0; }
} return score; }20:10 03-8-31 public String getMessages() { int length1=selection.length(); int length2=correctAnswer.length(); int length=Math.min(length1,length2); String message="正确答 案:"+correctAnswer.substring(0,length)+"\n"+
{ filename=name;
score=0; selection=""; try {
if(in!=null&&读取!=null) { in.close(); 读取.close(); }
f=new File(filename); in=new FileReader(f); 读取=new BufferedReader(in);
是否暂停计时=false; JButton 暂停或继续计时=null; public TestArea() {
list= new Choice(); String 当前目录=System.getProperty("user.dir"); File dir=new File(当前目录); FileName fileTxt=new FileName("txt"); String fileName[]=dir.list(fileTxt); for(int i=0;i<fileName.length;i++)
}); setVisible(true); setBounds(60,40,660,460); con.validate(); validate(); } public static void main(String args[]) {
new EnglishTest(); } }
//读取试题 ReadTestquestion import java.io.*; import java.util.*; public class ReadTestquestion { String filename="",
else { testContent=new String("没有选择试题"); }
} catch(Exception e)
{ testContent="试题内容为空,考试结束!!";
} return testContent; } public void setSelection(String s) { selection=selection+s; } public int getScore() { score=0; int length1=selection.length(); int length2=correctAnswer.length(); int min=Math.min(length1,length2); for(int i=0;i<min;i++)
}
class Enter implements ActionListener{ public void actionPerformed(ActionEvent e) {
if((f1.getText()).equals("tang")&&(f2.getText()).equals("051141")) {
p3.add(b3); cp.add(p1); cp.add(p2); cp.add(p3); b1.addActionListener(new Enter()); b2.addActionListener(new ReWrite()); b3.addActionListener(new Close()); } public static void main(String[] args) { Login log=new Login(); log.setTitle("系统登录"); log.setBounds(200, 200, 300, 300); log.setBackground(Color.blue); log.setVisible(true);
correctAnswer=(读取.readLine()).trim(); String temp=(读取.readLine()).trim() ; StringTokenizer token=new StringTokenizer(temp,":"); int hour=Integer.parseInt(token.nextToken()) ; int minute=Integer.parseInt(token.nextToken()); int second=Integer.parseInt(token.nextToken()); time=1000*(second+minute*60+hour*60*60);
Choice list=null; JTextArea 试题显示区=null,消息区=null; JCheckBox box[]; JButton 提交该题答案,读取下一题,查看分数; ReadTestquestion 读取试题=null; JLabel welcomeLabel=null; Thread countTime=null; long time=0; JTextField timeShow=null; boolean 是否关闭计时器=false,
correctAnswer="", testContent="" , selection="" ; int score=0; long time=0; boolean 完成考试=false; File f=null; FileReader in=null; BufferedReader 读取=null; public void setFilename(String name)
String str=null; FileName (String s) { str="."+s; }
public boolean accept(File dir,String name) { return name.endsWith(str); }
}
public class TestArea extends JPanel implements ActionListener,ItemListener,Runnable {
"你的回答:"+selection+"\n"; return message; }
}
//考试区域 TestArea
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; class FileName implements FilenameFilter {
相关主题