Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- BankAccount acc = new BankAccount();
- acc.setId(1);
- acc.setBalance(15);
- acc.withdraw(5);
- System.out.printf("Account ID%d, balance %.2f"
- ,acc.getId(),acc.getBalance());
- }
- }
- --------------------------------------
- package com.company;
- public class BankAccount {
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public double getBalance() {
- return balance;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public void deposit(double amaunt){
- this.balance+=amaunt;
- }
- public void withdraw(double amaunt){
- this.balance-=amaunt;
- }
- private double amaunt;
- private int id;
- private double balance;
- @Override
- public String toString(){
- return "ID" + this.id;
- }
- public BankAccount() {
- this.id = id;
- this.balance = balance;
- }
- }
Add Comment
Please, Sign In to add comment