Guest User

start of bank

a guest
Jul 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.41 KB | None | 0 0
  1. account
  2. ==================
  3. package Classes;
  4.  
  5. public class Account {
  6.  
  7.     protected String name;
  8.     protected static int totalAccount=0;
  9.     protected int loan;
  10.     protected int accountId;
  11.     protected double commission;
  12.     protected int personID;
  13.     protected double balance;
  14.     protected int misgeret;
  15.    
  16.     public Account(String name,  int personID)
  17.     {
  18.         this.name = name;
  19.         this.loan = 0;
  20.         this.commission = 0;
  21.         this.personID = personID;
  22.         this.balance=0;
  23.         this.misgeret=0;
  24.        
  25.         totalAccount+=1;
  26.         this.accountId = totalAccount; 
  27.     }
  28.    
  29.     public static int getTotalAccount()
  30.     {
  31.         return totalAccount;
  32.     }
  33.     public void deposit(int amount)
  34.     {
  35.         //give the amount after the bank take commission
  36.         this.balance+=amount*(1-(this.commission/100));
  37.     }
  38.  
  39.     public boolean withdraw(int amount)
  40.     {
  41.         double totalSumWithdraw=(amount*(1+(this.commission/100)));
  42.        
  43.         //check if we can withdraw
  44.         if (this.balance-totalSumWithdraw>this.misgeret)
  45.         {
  46.             return false;
  47.         }
  48.         //give the amount after the bank take commission
  49.         this.balance-=totalSumWithdraw;
  50.         return true;
  51.     }
  52.    
  53.     public boolean giveLoan(int amount)
  54.     {
  55.         boolean returnResult=false;
  56.         //give loan amount after the bank take commission
  57.         if (this.loan==0)
  58.         {
  59.             this.loan+=amount*(1-(this.commission/100));
  60.             returnResult=true;
  61.         }
  62.        
  63.         return returnResult;
  64.     }
  65.  
  66.     public int getMisgeret() {
  67.         return misgeret;
  68.     }
  69.  
  70.     public void setMisgeret(int misgeret) {
  71.         this.misgeret = misgeret;
  72.     }
  73.  
  74.     public String getName() {
  75.         return name;
  76.     }
  77.  
  78.     public void setName(String name) {
  79.         this.name = name;
  80.     }
  81.  
  82.     public double getCommission() {
  83.         return commission;
  84.     }
  85.  
  86.     public void setCommission(double commission) {
  87.         //we will make override for each account type
  88.     }
  89.  
  90.     public int getLoan() {
  91.         return loan;
  92.     }
  93.  
  94.     public int getAccountId() {
  95.         return accountId;
  96.     }
  97.  
  98.     public int getPersonID() {
  99.         return personID;
  100.     }
  101.  
  102.     public double getBalance() {
  103.         return balance;
  104.     }
  105.  
  106.     @Override
  107.     public String toString() {
  108.         //complate at home.... :)
  109.         return "";
  110.     }
  111. }
  112.  
  113. regular
  114. ================
  115. package Classes;
  116.  
  117. public class Regular extends Account{
  118.  
  119.     public Regular(String name, int personID) {
  120.         super(name, personID);
  121.         this.commission=utl.getRegularCommission();
  122.     }
  123.  
  124.     public void setCommission(double commission) {
  125.         if (commission<0)
  126.         {
  127.             this.commission=utl.getRegularCommission();
  128.             return;
  129.         }
  130.         this.commission=commission;
  131.     }
  132. }
Add Comment
Please, Sign In to add comment