Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by iamsomeone ( 13 years ago )
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testproject;

/**
 *
 * @author Aong
 */
public class BankAccount {
    private int id;  //user account
    private String name; //owner name
    private double balance; //remaining balance
    private static int n; //total account
    
    public BankAccount(String owner, double initBalance){
        name = owner;
        balance = initBalance;
        id = ++n;
    }
    
    public BankAccount(String owner){
        name = owner;
        balance = 0; // open account without initial balance
        id = ++n;
    }
    
    public static void totalAccount(){
        System.out.println("Total Bank Account: "+n);
    }
    
    public boolean deposit(double amount){
        balance+=amount;
        return true;
    }
    
    public boolean withdraw(double amount){
        if( balance < amount ) return false;
        balance-=amount;
        return true;
    }
    
    public void checkBalance(){
        System.out.println("Your remaining balance is: "+getBalance() );
    }
    
    private double getBalance(){
        return balance;
    }
}

 

Revise this Paste

Your Name: Code Language: