public class BankAccount { private static long id = 0; private String name; private long number; private long balance; public BankAccount(String name) { this.name = name; number = id++; balance = 0; } /** * Makes a deposit. * @param amount the amount to deposit * @return true if successful deposit, and false otherwise */ public boolean deposit(long amount) { if (amount < 0) return false; balance += amount; return true; } /** * Makes a withdrawal. * @param amount the amount to withdraw * @return true if the withdrawal is successful, and false otherwise */ public boolean withdraw(long amount) { if (amount < 0 || amount > balance) return false; balance -= amount; return true; } /** * @return balance */ public long getBalance() { return balance; } /** * @return String representation of this account */ public String toString() { return "[account number: " + number + ", account name: " + name + ", account balance: " + balance + "]"; } public static void main(String[] args) { BankAccount bill = new BankAccount("Bill Gates"); BankAccount jdoe = new BankAccount("Jill Doe"); bill.deposit(300000000000000L); jdoe.deposit(5); System.out.println("Jill's account current status is: " + jdoe); if (bill.withdraw(1)) System.out.println("Bill's account current status is: " + bill); else System.out.println("Bill's withdrawal was unsuccessful."); } }