Java Reference
In-Depth Information
surname = sname;
fi rstNames = fnames;
balance = bal;
}
//Methods…
public int getAcctNum()
{
return acctNum;
}
public String getName()
{
return (fi rstNames + " " + surname);
}
public double getBalance()
{
return balance;
}
public double withdraw(double amount)
{
if ((amount>0) && (amount<=balance))
return amount;
else
return 0;
}
public void deposit(double amount)
{
if (amount > 0)
balance += amount;
}
}
4. Create the server process.
The code for the server class sets up an ArrayList holding four initialised Account
objects and then creates an implementation object, using the ArrayList as the argu-
ment of the constructor. The reference to this object is bound to the programmer-
chosen name Accounts (which must be specifi ed as part of a URL identifying the
host machine) and placed in the registry. The server code is shown below.
import java.rmi.*;
import java.util.ArrayList;
public class Bank1Server
{
private static fi nal String HOST = "localhost";
Search WWH ::




Custom Search