if (line.equals("create")) {
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = (Account)rof.createRemoteObject(Account.class, line);
accounts.put(line, account);
System.out.println("\taccount "+line+" created");
}
else if (line.equals("withdraw"))
{
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
System.out.println("\tspecify amount");
System.out.print(">> ");
line = bis.readLine();
long amount = Long.parseLong(line);
try {
account.withdraw(amount);
System.out.println("\tamount "+amount+" withdrawn");
} catch (AccountException e) {
System.out.println("Exception occured: class= " + e.getClass().getCanonicalName());
System.out.println("Exception occured: message= " + e.getMessage());
}
catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("deposit"))
{
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
System.out.println("\tspecify ammount");
System.out.print(">> ");
line = bis.readLine();
long amount = Long.parseLong(line);
try {
account.deposit(amount);
System.out.println("\tamount "+amount+" deposited");
}
catch (AccountException e) {
System.out.println("Exception occured: class= " + e.getClass().getCanonicalName());
System.out.println("Exception occured: message= " + e.getMessage());
}
catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("balance"))
{
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
try{
long balance = account.balance();
System.out.println("\tbalance: "+balance);
}catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("number")) {
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
try{
String number = account.getAccountNumber();
System.out.println("\tnumber: "+number);
}catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("partner")) {
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
try{
Partner partner = account.getPartner();
if(partner == null)
{
System.out.println("\tno partner");
}
else
{
System.out.println("\tpartner");
System.out.println("\tfirstname: "+partner.getFirstName());
System.out.println("\tlastname: "+partner.getLastName());
}
}
catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("set number")) {
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
String number = "";
System.out.println("\tspecify number");
System.out.print(">> ");
number = bis.readLine();
try{
account.setAccountNumber(number);
System.out.println("\tnumber set: "+number);
}catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}
}
}
else if (line.equals("set partner")) {
System.out.println("\tspecify account id");
System.out.print(">> ");
line = bis.readLine();
Account account = accounts.get(line);
if(account == null)
System.out.println("\tno such account");
else
{
String firstName = "";
System.out.println("\tspecify first name");
System.out.print(">> ");
firstName = bis.readLine();
String lastName = "";
System.out.println("\tspecify last name");
System.out.print(">> ");
lastName = bis.readLine();
try{
Partner partner = new Partner(firstName, lastName);
account.setPartner(partner);
System.out.println("\tpartner set: "+partner);
}catch(SimpleRpcException e)
{
System.out.println("\t "+e.getMessage());
}