deyanmalinov

1. Define Bank Account Class

May 19th, 2020
233
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         BankAccount acc = new BankAccount();
  5.         acc.setId(1);
  6.         acc.setBalance(15);
  7.         acc.withdraw(5);
  8.         System.out.printf("Account ID%d, balance %.2f"
  9.                 ,acc.getId(),acc.getBalance());
  10.     }
  11. }
  12. --------------------------------------
  13. package com.company;
  14. public class BankAccount {
  15.     public int getId() {
  16.         return id;
  17.     }
  18.     public void setId(int id) {
  19.         this.id = id;
  20.     }
  21.     public double getBalance() {
  22.         return balance;
  23.     }
  24.     public void setBalance(double balance) {
  25.         this.balance = balance;
  26.     }
  27.     public void deposit(double amaunt){
  28.         this.balance+=amaunt;
  29.     }
  30.     public void withdraw(double amaunt){
  31.         this.balance-=amaunt;
  32.     }
  33.     private double amaunt;
  34.     private int id;
  35.     private double balance;
  36.     @Override
  37.     public String toString(){
  38.         return "ID" + this.id;
  39.     }
  40.     public BankAccount() {
  41.         this.id = id;
  42.         this.balance = balance;
  43.     }
  44. }
RAW Paste Data