⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentinfoimpl.java

📁 基于RMI的学生成绩管理程序,实现了线程,事件模型.
💻 JAVA
字号:
/*
 * StudentinfoImpl.java
 *
 * Created on 2005年11月23日, 下午1:41
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */



/**
 *
 * @author 和尚
 */

    
    /** Creates a new instance of StudentinfoImpl */
import java.rmi.*;
import java.rmi.server.*;
import javax.swing.*;
import java.lang.String;
import java.lang.Object;
import java.util.*;
import java.lang.Thread;

public class StudentinfoImpl extends UnicastRemoteObject implements Studentinfo,ScoreListener,Runnable {
    
    /** Creates a new instance of StudentinfoImpl */

    private int x,mark;
    private Thread iThread;
    private int iNumber;
    private Random iRandom;
    boolean ihaveClicked=false;
    boolean iflogon=false;
    boolean iflookup=false;
    private Vector iTutor=new Vector();
    String[] s=new String[2];
    String[] n={"aa","bb","cc"};
    String[] p={"11","22","33"};
    String[] f=new String[3];
    String[] s1={"xx","yy","zz"};
    String[] s2={"mm","nn","ll"};
    String[] s3={"66","77","88"};
    int i,j;
    public StudentinfoImpl() throws RemoteException { 
        iThread = new Thread(this);
        iThread.start();
    }

    public void logoff() throws RemoteException {
        System.exit(0);
    }

        public void run(){
            while(true){              
                if(ihaveClicked){
                    try{
		    System.out.println("44");   
                    JOptionPane.showMessageDialog(null,"Add score successfully!","Tutor",JOptionPane.PLAIN_MESSAGE); 
                    String input1=JOptionPane.showInputDialog("input a student's name");
	            String addstudentname=String.valueOf(input1);
                    String input2=JOptionPane.showInputDialog("input a couse");
	           String addcousename=String.valueOf(input2);
                   String input3=JOptionPane.showInputDialog("input the mark");
	           String addmarkname=String.valueOf(input3);
                  // addstudentscore(input1,input2,input3);
                  //  x=s1.length;
			System.out.println("aa");
                  s1[x+1]=String.valueOf(addstudentname);
                  s2[x+1]=String.valueOf(addcousename);
                   s3[x+1]=String.valueOf(addmarkname);
                    JOptionPane.showMessageDialog(null,"Add score successfully!","Tutor",JOptionPane.PLAIN_MESSAGE);
                    ihaveClicked=false;
                    System.out.println("bbbb");
                   }
                  catch(Exception e){e.printStackTrace();}
		    
                }
                else if(!ihaveClicked) {
                   System.out.println("fff"); 
                   String input1=JOptionPane.showInputDialog("input a student's name");
                    JOptionPane.showMessageDialog(null,input1,"Tutor",JOptionPane.PLAIN_MESSAGE); 
                   iThread.suspend();
                   }
            }
        }
    public int logon(String username, String password) throws RemoteException {
            s[0]=username;
            s[1]=password;
	    for(int i=0;i<3;i=i+1){
		if (n[i].equals(s[0])&&p[i].equals(s[1])){	
			    iflogon=true;
			}

           }
        if (iflogon==true) {JOptionPane.showMessageDialog(null,"logon successfully!","Message",JOptionPane.PLAIN_MESSAGE);
                 return 1;}
        if(iflogon==false) {JOptionPane.showMessageDialog(null,"your username or password is not correct,please check","Message",JOptionPane.PLAIN_MESSAGE);}
            return 0;
    }
 
    public int lookup(String studentname,String course) throws RemoteException{
             f[0]=studentname;
             f[1]=course;
             int y;
             for(int j=0;j<3;j=j+1){
                if(s1[j].equals(f[0])&&s2[j].equals(f[1])) {
                 //y=Integer.parseInt(s3[l]);                    
                 iflookup=true;
                }
             }
             if(iflookup==true){
             JOptionPane.showMessageDialog(null,"lookup successfully!","Message",JOptionPane.PLAIN_MESSAGE);
             y=Integer.parseInt(s3[j]);                
             return y;             
             }
             if(iflookup==false){ JOptionPane.showMessageDialog(null,"Something Error, try again!","Studnet",JOptionPane.PLAIN_MESSAGE);}
             return 0;
            }

         



        public synchronized void scoreStatus(ScoreEvent anEvent){
	 
		if(!ihaveClicked){		
		ihaveClicked=true;
		iThread.resume();
		}
        }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -