Skip to content

Instantly share code, notes, and snippets.

@kobigurk
Created July 6, 2016 17:25
Show Gist options
  • Save kobigurk/0e41309c975d20db18efdbd26f248ed9 to your computer and use it in GitHub Desktop.
Save kobigurk/0e41309c975d20db18efdbd26f248ed9 to your computer and use it in GitHub Desktop.
class Bank {
int[] balances = {0, 100, 0};
void send(int from, int to, int amount) {
if (balances[from] >= amount) {
balances[from] -= amount;
balances[to] += amount;
}
}
void printBalances() {
for (int i = 0; i < balances.length; i++) {
System.Out.printLn(balances[i]);
}
}
}
public static void main(String[] args) {
Bank bank = new Bank();
bank.send(1, 0, 50);
bank.printBalances();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment