public interface BankAccount extends java.rmi.Remote {
/**
* 存钱
* @param account
* @throws java.rmi.RemoteException
*/
public void deposit(float account) throws java.rmi.RemoteException;
/**
* 取钱
* @param account
* @throws java.rmi.RemoteException
*/
public void withdraw(float account) throws java.rmi.RemoteException;
/**
* 平衡
* @throws java.rmi.RemoteException
*/
public void getBalance() throws java.rmi.RemoteException;
}
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class BankAccountImp extends UnicastRemoteObject implements BankAccount {
@SuppressWarnings("unused")
private float balance = 0;
public BankAccountImp(float initBalance) throws RemoteException {
this.balance = initBalance;
}
public void deposit(float account) throws RemoteException {
System.out.println("Depost:" + account);
}
public void getBalance() throws RemoteException {
System.out.println("Balance");
}
public void withdraw(float account) throws RemoteException {
System.out.println("Withdraw:" + account);
}
}