Created
June 15, 2016 16:34
-
-
Save kobigurk/49344bd5319622d5599c03f1f42d599c 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