Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- import java.math.BigInteger;
- public class Account {
- private BigInteger getNumerKonta;
- private String accountOwner;
- private BigDecimal ballance ;
- private int pin;
- public int getPin() {
- return pin;
- }
- public void setPin(int pin) {
- this.pin = pin;
- }
- public Account(BigInteger nr, String owner, BigDecimal ballance) {
- this.getNumerKonta = nr;
- this.accountOwner = owner;
- this.ballance = ballance;
- }
- public BigInteger getAccountNumber() {
- return getNumerKonta;
- }
- public void setNumerKonta(BigInteger numerKonta) {
- this.getNumerKonta = numerKonta;
- }
- public String getAccountOwner() {
- return accountOwner;
- }
- public void setAccountOwner(String accountOwner) {
- this.accountOwner = accountOwner;
- }
- public BigDecimal getBallance() {
- return ballance;
- }
- public void setBallance(BigDecimal ballance) {
- this.ballance = ballance;
- }
- public BigDecimal getCash(BigDecimal howMuch) throws MyNoEnoughCashOnAccountException {
- BigDecimal result = this.ballance.subtract(howMuch);
- if (result.intValue() >= 0) { // OK
- return result;
- } else {
- throw new MyNoEnoughCashOnAccountException("Brak wystarczających funduszy na koncie");
- }
- }
- public void putCash(BigDecimal howMuch) {
- BigDecimal result = this.getBallance().add(howMuch);
- this.ballance = result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement