Advertisement
vangivang

AutoUpdater class

Jun 30th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3.  
  4. public class AutoUpdater implements Runnable
  5. {
  6.  
  7.     private ArrayList<Client> updaterClientList;
  8.     long time;
  9.    
  10.     public AutoUpdater()
  11.     {
  12.         updaterClientList = new ArrayList<Client>();
  13.         time = 86400000; //24 hours
  14.     }
  15.  
  16.     public void run()
  17.     {
  18.         try
  19.         {
  20.             autoUpdateAccounts();
  21.             Thread.sleep(time);
  22.         }
  23.         catch (Exception e)
  24.         {
  25.             e.printStackTrace();
  26.         }
  27.     }
  28.    
  29.     private void autoUpdateAccounts() throws Exception
  30.     {
  31.         updaterClientList = Bank.getInstance().getClients();
  32.         for (Client clnt : updaterClientList)
  33.         {
  34.             float newClientBalance =clnt.getBalance() + (clnt.getBalance() *
  35.                                     clnt.getInterestRate());
  36.             clnt.setClientBalance(newClientBalance);
  37.         }
  38.         Bank.getInstance().setClients(updaterClientList);
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement