For this method, no separate Account class is used. Instead, the data and methods
associated with an individual account will be defi ned directly in the implementation
class. The interface will make the methods available to client processes. The same
four steps as were identifi ed in Sect. 5.2 must be carried out, as described below.
1. Create the interface.
The same fi ve methods that appeared in class Account in Method 1 are declared, but
with each now declaring that it throws a RemoteException .
public interface Bank2 extends Remote
public int getAcctNum()throws RemoteException;
public String getName()throws RemoteException;
public double getBalance()throws RemoteException;
public double withdraw(double amount)
public void deposit(double amount)
2. Defi ne the implementation.
As well as holding the data and method implementations associated with an indi-
vidual account, this class defi nes a constructor for implementation objects. The
method defi nitions will be identical to those that were previously held within the
Account class, of course.
public class Bank2Impl extends UnicastRemoteObject
private int acctNum;
private String surname;
private String fi rstNames;
private double balance;
//Constructor for implementation objects…
public Bank2Impl(int acctNo, String sname,
String fnames, double bal) throws RemoteException
acctNum = acctNo;
surname = sname;
fi rstNames = fnames;
balance = bal;