Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class AutoUpdater implements Runnable
- {
- private ArrayList<Client> updaterClientList;
- long time;
- public AutoUpdater()
- {
- updaterClientList = new ArrayList<Client>();
- time = 86400000; //24 hours
- }
- public void run()
- {
- try
- {
- autoUpdateAccounts();
- Thread.sleep(time);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- private void autoUpdateAccounts() throws Exception
- {
- updaterClientList = Bank.getInstance().getClients();
- for (Client clnt : updaterClientList)
- {
- float newClientBalance =clnt.getBalance() + (clnt.getBalance() *
- clnt.getInterestRate());
- clnt.setClientBalance(newClientBalance);
- }
- Bank.getInstance().setClients(updaterClientList);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement