Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 0.73 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.*;
  2.  
  3. /**
  4.  *
  5.  * @author Linus
  6.  */
  7. public class AccountRegister {
  8.  
  9.   ArrayList<Account> list = new ArrayList<Account>();
  10.   Account account;
  11.  
  12.   AccountRegister(){
  13.   }
  14.  
  15.   public void createNewAccount(String name, double amount){
  16.     account = new Account(name, amount);
  17.     list.add(account);
  18.   }
  19.  
  20.   public Account findAccount(String id){
  21.     for(Account account : list){
  22.         System.out.println(account.getName());
  23.       if (account.getName().equals(id)){
  24.         return account;
  25.       }
  26.     }
  27.     return null;
  28.   }
  29.  
  30.   public void deleteAccount(String id){
  31.     for(Account account : list){
  32.       if (account.getAccountNbr().equals(id)){
  33.         list.remove(account);
  34.       }
  35.     }    
  36.   }
  37. }