//主类EnglishTest——import .*;import .*;import .*;public class EnglishTest extends JFrame{ TestArea testPanel=null; Container con=null; public EnglishTest() { super("模拟考试"); testPanel=new TestArea(); con=getContentPane(); (testPanel,); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { (0); } }); setVisible(true); setBounds(60,40,660,460); (); validate(); } public static void main(String args[]) { new EnglishTest(); }}//读取试题 ReadTestquestionimport .*;import .*;public class ReadTestquestion{ String filename="", correctAnswer="", testContent="" , selection="" ; int score=0; long time=0; boolean 完成考试=false; File f=null; FileReader in=null; BufferedReader 读取=null; public void setFilename(String name) { filename=name; score=0; selection=""; try { if(in!=null&&读取!=null) { (); 读取.close(); } f=new File(filename); in=new FileReader(f); 读取=new BufferedReader(in); correctAnswer=(读取.readLine()).trim(); String temp=(读取.readLine()).trim() ; StringTokenizer token=new StringTokenizer(temp,":"); int hour=(()) ; int minute=(()); int second=(()); time=1000*(second+minute*60+hour*60*60); } catch(Exception e) { testContent="没有选择试题"; } } public String getFilename() { return filename; } public long getTime() { return time; } 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(("**")) break; ("\n"+s); if(("endend")) { (); 读取.close(); 完成考试=true; } } testContent=new String(temp); } 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=(); int length2=(); int min=(length1,length2); for(int i=0;i=1) { time=time-1000; long leftTime=time/1000; long leftHour=leftTime/3600; long leftMinute=(leftTime-leftHour*3600)/60; long leftSecond=leftTime%60; (""+leftHour+"小时"+leftMinute+"分"+leftSecond+"秒"); } try { (1000); } catch(InterruptedException ee) { if(是否关闭计时器==true) return ; } while(是否暂停计时==true) { try { wait(); } catch(InterruptedException ee) { if(是否暂停计时==false) { notifyAll(); } } } } } }