Advertisement
dawciobiel

Account

Apr 15th, 2020
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.math.BigInteger;
  3.  
  4. public class Account {
  5.  
  6.     private BigInteger getNumerKonta;
  7.     private String accountOwner;
  8.     private BigDecimal ballance ;
  9.     private int pin;
  10.    
  11.     public int getPin() {
  12.         return pin;
  13.     }
  14.  
  15.     public void setPin(int pin) {
  16.         this.pin = pin;
  17.     }
  18.  
  19.     public Account(BigInteger nr, String owner, BigDecimal ballance) {
  20.         this.getNumerKonta = nr;
  21.         this.accountOwner = owner;
  22.         this.ballance = ballance;
  23.        
  24.     }
  25.  
  26.     public BigInteger getAccountNumber() {
  27.         return getNumerKonta;
  28.     }
  29.  
  30.     public void setNumerKonta(BigInteger numerKonta) {
  31.         this.getNumerKonta = numerKonta;
  32.     }
  33.  
  34.     public String getAccountOwner() {
  35.         return accountOwner;
  36.     }
  37.  
  38.     public void setAccountOwner(String accountOwner) {
  39.         this.accountOwner = accountOwner;
  40.     }
  41.  
  42.     public BigDecimal getBallance() {
  43.         return ballance;
  44.     }
  45.  
  46.     public void setBallance(BigDecimal ballance) {
  47.         this.ballance = ballance;
  48.     }
  49.    
  50.     public BigDecimal getCash(BigDecimal howMuch) throws MyNoEnoughCashOnAccountException {
  51.         BigDecimal result = this.ballance.subtract(howMuch);
  52.         if (result.intValue() >= 0) { // OK
  53.             return result;
  54.         } else {
  55.             throw new MyNoEnoughCashOnAccountException("Brak wystarczających funduszy na koncie");
  56.         }      
  57.     }
  58.    
  59.     public void putCash(BigDecimal howMuch) {
  60.         BigDecimal result = this.getBallance().add(howMuch);
  61.         this.ballance = result;
  62.        
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement