• 大小: 7KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: Java
  • 标签: 考试系统  

资源简介

这是一个用java语言编写的简单的客户端和服务器端考试的小软件,简单易用.

资源截图

代码片段和文件信息

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class ChoiceFile extends Panel implements ItemListenerActionListenerRunnable
{
   Button 得到试题文件=null;
   Choice list=null; 
   Socket  socket=null;
   DataInputStream in=null; 
   DataOutputStream out=null; 
   Thread thread=null;
   boolean success=false isSelected=false;
   int n=0;
   
   public ChoiceFile()
    {
      得到试题文件=new Button(“将试题文件添加到下拉列表中“);
      得到试题文件.setEnabled(false);
      得到试题文件.addActionListener(this);
      list=new Choice();
      list.add(“**********“);
      add(得到试题文件);
      add(list);
      list.addItemListener(this);
      thread=new Thread(this);
    }
  public void setSocketConnection(Socket socketDataInputStream inDataOutputStream out)
    {
      this.socket=socket;
      this.in=in;
      this.out=out; 
      try {
            thread.start(); 
          }
      catch(Exception ee)
          {
          }
      if(this.socket!=null)
       {
         得到试题文件.setEnabled(true);
       } 
    }
   public void actionPerformed(ActionEvent e)
    {
         try 
           { 
             out.writeUTF(“列出考试文件“);
           }
           catch(IOException ee)
           { 
             success=false;
           }
       
    } 
  public void itemStateChanged(ItemEvent e)
    { 
      n=list.getItemCount();
      if(n>=1&&isSelected==true)
        {
          String listItem=list.getSelectedItem();
           try
              {
                out.writeUTF(“考试文件的名字:“+listItem);
                out.writeUTF(“请通知考试界面考试用时:“);
              }
           catch(IOException ee)
              {
              }
        }         
   }
  public String 得到选择的文件名()
   {
    return list.getSelectedItem();
   }
  public void run()
   {
    String s=null;
    list.removeAll();
    while(true)
      { 
        try
           {
             s=in.readUTF();          
              if(s.startsWith(“考试文件:“))
                 {
                   String listItem=s.substring(s.indexOf(“:“)+1);
                   list.add(listItem);
                   isSelected=true;
                 }
               if(s.startsWith(“已经全部列出:“))
                 {
                   success=true; 
                   break;
                 }
               
           }
        catch (Exception ee) 
           {
           }   
      }
 }
 public boolean getSuccess()
 { 
   n=list.getItemCount();
   if(n>0&&success==true)
      return true;
   else
      return false;
 }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2721  2003-09-10 22:07  chap7考试系统(BS)\ChoiceFile.java

     文件       3235  2003-12-25 14:42  chap7考试系统(BS)\ClientBS.java

     文件       6319  2003-09-10 22:08  chap7考试系统(BS)\ClientTestArea.java

     文件       3856  2003-12-21 23:03  chap7考试系统(BS)\ReadTestquestion.java

     文件       4303  2003-12-09 09:02  chap7考试系统(BS)\Server.java

     目录          0  2003-12-16 09:00  chap7考试系统(BS)

----------- ---------  ---------- -----  ----

                20434                    6


评论

共有 条评论