Advertisement
spiny94

Untitled

Sep 14th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public void transfer(int fromCode, int toCode, int date, double value)
  2. throws InvalidCode, InvalidValue {
  3. if (!accounts.containsKey(fromCode) || !accounts.containsKey(toCode)) {
  4. throw new InvalidCode();
  5. }
  6. // double s = accounts.get(fromCode).getValue();
  7. // double s = accounts.get(fromCode).getBalance();
  8. // if (s > accounts.get(toCode).getValue()) {
  9.  
  10. // if (value > s) {
  11. if (value > accounts.get(fromCode).getBalance()) {
  12. throw new InvalidValue();
  13. } else {
  14. // double t = accounts.get(toCode).getValue();
  15. // double t = accounts.get(toCode).getBalance();
  16. // double t;
  17. // t = s- value;
  18. accounts.get(fromCode).subtractFromBalance(date, value);
  19. // accounts.get(toCode).addToBalance( value);
  20. accounts.get(toCode).addToBalance(date, value);
  21. // t += s;
  22.  
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement