studentimpl.java

来自「北京大学出版社的」· Java 代码 · 共 46 行

JAVA
46
字号
package examples.network;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/** An implementation of the Student interface as a
  * remote object
  */
public class StudentImpl extends UnicastRemoteObject
                         implements Student {
   private int ID;
   private String name;
   private int credits = 0;
   /** Construct and register the student object
     */
   public StudentImpl( int ID, String name )
                     throws RemoteException {
      this.ID = ID;
      this.name = name;
   }
   /** Return the student's identification number
     */
   public int getID() throws RemoteException {
      return ID;
   }
   /** Change the student's name
     */
   public void setName( String name )
                      throws RemoteException {
      this.name = name;
   }
   /** Return the student's name
     */
   public String getName() throws RemoteException {
      return name;
   }
   /** Return the current number of course credits
     */
   public int getCredits() throws RemoteException {
      return credits;
   }
   /** Add course credits and return the new total
     */
   public int addCredits( int credits )
                        throws RemoteException {
      return ( this.credits += credits );
   }
}

⌨️ 快捷键说明

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