/* odd version with all static methods only !!! DO NOT WRITE CODE LIKE THAT !!! */ public class BankAccount { private int balance = 0; private int id = 0; public static int getBalance(BankAccount ba) { return ba.balance; } public static void deposit(BankAccount ba, int amount) { System.out.println("Depositing " + amount + "$ into account " + ba.id); ba.balance = ba.balance + amount; } public static void withdraw(BankAccount ba, int amount) { if (amount > ba.balance) { amount = ba.balance; System.out.println("No overdraft facility, will only withdraw " + amount + "$ from account " + ba.id); } System.out.println("Withdrawing " + amount + "$ from account " + ba.id); ba.balance = ba.balance - amount; } public static int transaction(BankAccount ba, int amount) { if (amount > 0) ba.deposit(amount); else ba.withdraw(-amount); return ba.balance; } public static String toString(BankAccount ba) { return ""; } private static int idCounter = 0; public BankAccount() { id = idCounter++; System.out.println("Created new account with Id = " + id); } public BankAccount(int initialBalance) { id = idCounter++; System.out.println("Created new account with Id = " + id); // HOW TO DO THAT ??? we will learn that later //transaction(initialBalance); } }