Java Reference
In-Depth Information
public int getAcctNum() throws RemoteException
{
return acctNum;
}
public String getName() throws RemoteException
{
return (fi rstNames + " " + surname);
}
public double getBalance() throws RemoteException
{
return balance;
}
public double withdraw(double amount)
throws RemoteException
{
if ((amount>0) && (amount<=balance))
return amount;
else
return 0;
}
public void deposit(double amount)
throws RemoteException
{
if (amount > 0)
balance += amount;
}
}
3. Create the server process.
The server class creates an array of implementation objects and binds each one
individually to the registry. The name used for each object will be formed from
concatenating the associated account number onto the word 'Account' (forming
'Account111111', etc.).
import java.rmi.*;
public class Bank2Server
{
private static fi nal String HOST = "localhost";
public static void main(String[] args)
throws Exception
{
//Create array of initialised implementation
Search WWH ::




Custom Search