Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- String arg0 = args[0];
- AccountBST mainBST = new AccountBST();
- BufferedReader br = new BufferedReader(new FileReader(args[0]));
- String s=br.readLine();
- String [] tokens = s.split(" ");
- while(s!=null)
- {
- int accNum = Integer.parseInt(tokens[0]);
- char tType = tokens[1].charAt(0);
- float amount = Float.parseFloat(tokens[2]);
- if (mainBST.find(accNum)==null)
- {
- if (tType=='d')
- {
- mainBST.insert(accNum, amount);
- System.out.print("DEPOSIT");
- System.out.println("");
- }
- else if (tType=='w')
- {
- mainBST.insert(accNum, -amount);
- System.out.print("WITHDRAW");
- System.out.println("");
- }
- }
- else
- {
- if (tType=='d')
- {
- mainBST.find(accNum).setBalance(amount);
- System.out.print("DEPOSIT");
- System.out.println("");
- }
- if (tType=='w')
- {
- mainBST.find(accNum).setBalance(-amount);
- System.out.print("WITHDRAW");
- System.out.println("");
- }
- if (tType=='c')
- {
- mainBST.remove(accNum);
- System.out.print("CLOSE");
- System.out.println("");
- }
- }
- s=br.readLine();
- tokens = s.split(" ");
- }
- System.out.print("RESULT:");
- mainBST.traverse(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement