Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void transfer(int fromCode, int toCode, int date, double value)
- throws InvalidCode, InvalidValue {
- if (!accounts.containsKey(fromCode) || !accounts.containsKey(toCode)) {
- throw new InvalidCode();
- }
- // double s = accounts.get(fromCode).getValue();
- // double s = accounts.get(fromCode).getBalance();
- // if (s > accounts.get(toCode).getValue()) {
- // if (value > s) {
- if (value > accounts.get(fromCode).getBalance()) {
- throw new InvalidValue();
- } else {
- // double t = accounts.get(toCode).getValue();
- // double t = accounts.get(toCode).getBalance();
- // double t;
- // t = s- value;
- accounts.get(fromCode).subtractFromBalance(date, value);
- // accounts.get(toCode).addToBalance( value);
- accounts.get(toCode).addToBalance(date, value);
- // t += s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement