Created
July 6, 2016 17:25
-
-
Save kobigurk/0e41309c975d20db18efdbd26f248ed9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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