class BankAccount{
private long balance;
private int acctnum;
//Constructor to initialize balance and account number
public BankAccount(long initial, int acctNum){
balance = initial;
acctnum = acctNum;
}
//Withdraw is synchonized to avoid overlap
//method returns a boolen to see if account is overdrawn
public synchronized boolean withdraw(long amount){
if(amount<=balance){
long newBalance = balance - amount;
balance = newBalance;
return false;
}
else
System.out.print("Account Overdrawn!" + acctnum);
return true;
}
//Here lets add a method to calclate interest
//
public long getbalance(){
return balance;
}
public int getacct(){
return acctnum;
}
}