All pastes #387530 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-09 12:53 UTC
rendered paste body
// EDS CORBA 2.6 Xuepeng Deng 28/02/07
 
// JDK1.4.2 with JacORB 2.2
 
// bank\ManagerImpl.java
 
// servant implementation
 
package bank;
 
import java.io.*;
import org.omg.CORBA.ORB;
import java.lang.Math;
import javax.naming.*;
import java.rmi.*;
import java.util.Hashtable;
 
import org.omg.PortableServer.*;
import org.omg.CosNaming.*;
 
 
public class ManagerImpl extends ManagerPOA
 
{
		//Using HashTable to store the accounts.
        private Hashtable accountsList;
        private Account bankAccount;
        private ORB orb;
        
        //Need this for createing interface: Account;
        public ManagerImpl(ORB orb)
        {
                this.orb = orb;
        };
        
        //This is the method to return a array of all accounts.
        public String[] findAllAccounts() {
                
                //YOU NEED TO CONVERT THE HASHTABLE TO A STRING ARRAY!!!!!!!!!!!
 
               //JUST CREATING AN ARRAY WITH SOME VALUES!!!!!!!1111
               String[] a = new String[2];
                a[0] = "String 1";
                a[1] = "String 2";
 
 
                 //CALLING THE SIZE METHOD OF YOUR HASHTABLE NUMBER WILL GET BIGGER THE MORE ACCOUNTS THAT ARE ADDED
                   System.out.println("Size" + accountsList.size());
                return a;
        }
        
        
        //This is the method to create a new account.
        public Account createAccount(String name, int balance)  {
                AccountImpl newAccount = new AccountImpl(name,balance);
                Account accountObj = newAccount._this(orb);
                // Creat a hashtable to add the new account
                try {
                        //ADD TO HASHTABLE   
                        accountsList.put(name,accountObj);
        
                }     
                catch (Exception e) {
                System.out.println("Error while looking up account:");
                //e.printStackTrace();
            }
 
                //obj.setAccountName(name);
                //obj.setBalance(balance);
                return accountObj;
        }
        
        //Retrun a specific account object;
		public Account findAccount(String name){
			//AccountImpl newAccount = new AccountImpl(name,0);
			//Account bankAccount = newAccount._this(orb);
			bankAccount = (Account) accountsList.get(name);
			return bankAccount;
		}
		
		
}