Advertisement
spiny94

Untitled

Sep 11th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.85 KB | None | 0 0
  1. package Main;
  2.  
  3. import BankServices.Account;
  4. import BankServices.Bank;
  5. import BankServices.Deposit;
  6. import BankServices.InvalidCode;
  7. import BankServices.InvalidValue;
  8. import BankServices.Operation;
  9. import BankServices.Withdrawal;
  10.  
  11. public class MainClass {
  12.  
  13.     public static void main(String[] args) {
  14.         Bank b1 = new Bank("Uncle-$crooge");
  15.         int c1 = b1.createAccount("John", 5, 500.5);
  16.         int c2 = b1.createAccount("Mary", 10,  1000.);
  17.         int c3 = b1.createAccount("John", 20,  800.);
  18.         int c4 = b1.createAccount("Paul", 30, 252.4);
  19.         Account a1=null, a3=null;
  20.        
  21.         try {
  22.             b1.deposit(c1, 7, 360.0);
  23.             b1.deposit(c4, 35, 270.0);
  24.             b1.withdraw(c3, 28, 350.0);
  25.             b1.withdraw(c2, 19, 350.0);
  26.             b1.withdraw(c3, 41, 158.0);
  27.             b1.transfer(c1, c3, 8, 400.0);
  28.             a1 = b1.getAccount(c1);
  29.             a3 = b1.deleteAccount(c3,50);
  30.         }
  31.         catch(InvalidCode ic) {
  32.             ic.printStackTrace();
  33.         }
  34.         catch(InvalidValue iv) {
  35.             iv.printStackTrace();
  36.         }
  37.        
  38.         for(Account a : b1.getAccounts()) {
  39.             System.out.println("account: " + a);
  40.             System.out.println(" movements:");
  41.             for(Operation o : a.getMovements())
  42.                 System.out.println(o);
  43.             System.out.println();
  44.         }
  45.        
  46. /*      account: 1,John,8,460.5
  47.          movements:
  48.         8,400.0-
  49.         7,360.0+
  50.         5,500.5+
  51.  
  52.         account: 2,Mary,19,650.0
  53.          movements:
  54.         19,350.0-
  55.         10,1000.0+
  56.  
  57.         account: 4,Paul,35,522.4
  58.          movements:
  59.         35,270.0+
  60.         30,252.4+
  61. */     
  62.         System.out.println("deleted account: " + a3);
  63.         System.out.println(" movements:");
  64.         for(Operation o : a3.getMovements())
  65.             System.out.println(o);
  66.         System.out.println();
  67.        
  68. /*      deleted account: 3,John,50,0.0
  69.          movements:
  70.         50,692.0-
  71.         41,400.0+
  72.         41,158.0-
  73.         28,350.0-
  74.         20,800.0+
  75. */     
  76.         System.out.println("account: " + a1);
  77.         System.out.println(" movements:");
  78.         for(Operation o : a1.getMovements())
  79.             System.out.println(o);     
  80.         System.out.println(" deposits:");
  81.         for(Deposit d : a1.getDeposits())
  82.             System.out.println(d);     
  83.         System.out.println(" withdrawals:");
  84.         for(Withdrawal w : a1.getWithdrawals())
  85.             System.out.println(w);
  86.         System.out.println();
  87.        
  88. /*      account: 1,John,8,460.5
  89.          movements:
  90.         8,400.0-
  91.         7,360.0+
  92.         5,500.5+
  93.          deposits:
  94.         5,500.5+
  95.         7,360.0+
  96.          withdrawals:
  97.         8,400.0-
  98. */     
  99.         System.out.println("total deposit in the " + b1.getName() + " bank: " + b1.getTotalDeposit());
  100.         System.out.println();
  101.        
  102. //      total deposit in the Uncle-$crooge bank: 1632.9
  103.        
  104.         System.out.println("accounts with balance higher than 500: " + b1.getPerCentHigher(500) + " %");
  105.         System.out.println();
  106.        
  107. //      accounts with balance higher than 500: 66.0 %
  108.        
  109.         System.out.println("accounts with balance in range 500..700 :");
  110.         for(Account a : b1.getAccountsByBalance(500, 700))
  111.             System.out.println(a);
  112.         System.out.println();
  113.        
  114. /*      accounts with balance in range 500..700 :
  115.             2,Mary,19,650.0
  116.             4,Paul,35,522.4
  117. */         
  118.     }
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement