Advertisement
Guest User

Untitled

a guest
May 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. try
  2. {
  3. String arg0 = args[0];
  4. AccountBST mainBST = new AccountBST();
  5.  
  6. BufferedReader br = new BufferedReader(new FileReader(args[0]));
  7. String s=br.readLine();
  8. String [] tokens = s.split(" ");
  9.  
  10. while(s!=null)
  11. {
  12. int accNum = Integer.parseInt(tokens[0]);
  13. char tType = tokens[1].charAt(0);
  14. float amount = Float.parseFloat(tokens[2]);
  15.  
  16. if (mainBST.find(accNum)==null)
  17. {
  18. if (tType=='d')
  19. {
  20. mainBST.insert(accNum, amount);
  21. System.out.print("DEPOSIT");
  22. System.out.println("");
  23. }
  24. else if (tType=='w')
  25. {
  26. mainBST.insert(accNum, -amount);
  27. System.out.print("WITHDRAW");
  28. System.out.println("");
  29. }
  30. }
  31. else
  32. {
  33. if (tType=='d')
  34. {
  35. mainBST.find(accNum).setBalance(amount);
  36. System.out.print("DEPOSIT");
  37. System.out.println("");
  38. }
  39. if (tType=='w')
  40. {
  41. mainBST.find(accNum).setBalance(-amount);
  42. System.out.print("WITHDRAW");
  43. System.out.println("");
  44. }
  45. if (tType=='c')
  46. {
  47. mainBST.remove(accNum);
  48. System.out.print("CLOSE");
  49. System.out.println("");
  50. }
  51. }
  52.  
  53. s=br.readLine();
  54. tokens = s.split(" ");
  55. }
  56.  
  57. System.out.print("RESULT:");
  58. mainBST.traverse(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement