-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClient_201501169.java
More file actions
97 lines (77 loc) · 3.37 KB
/
Copy pathClient_201501169.java
File metadata and controls
97 lines (77 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.*;
import java.text.*;
public class Client_201501169 {
private Client_201501169() {}
public static void main(String[] args) {
try {
// Getting the registry
Registry registry = LocateRegistry.getRegistry(null);
// Looking up the registry for the remote object
Interface_201501169 stub = (Interface_201501169) registry.lookup("Interface_201501169");
// Calling the remote method using the obtained object
// stub.printAccounts();
// String inputStringS = "11-11-2012";
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
// Date startDate = dateFormat.parse(inputStringS);
// String inputStringE = "12-11-2018";
// // DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
// Date endDate = dateFormat.parse(inputStringE);
// System.out.println(stub.transaction_details("1", startDate, endDate));
Scanner scan = new Scanner(System.in);
while(1==1){
System.out.print(">>");
String str = scan.nextLine();
String[] splited = str.split("\\s+");
if(splited[0].equals("deposit") ){
System.out.println(stub.deposit(splited[1], Double.parseDouble(splited[2])));
}
else if(splited[0].equals("withdraw") ){
System.out.println(stub.withdraw(splited[1], Double.parseDouble(splited[2])));
}
else if(splited[0].equals("balance") ){
System.out.println(stub.balance(splited[1])) ;
}
else if(splited[0].equals("transaction_details") ){
if(splited.length == 2){
String csv = stub.transaction_details(splited[1]);
System.out.printf("| %-5s", "ID");
System.out.printf("| %-28s", "TIME");
System.out.printf("| %-5s", "AMOUNT");
System.out.printf("| %-5s", "BALANCE\n");
String[] rows = csv.split("\n");
for(String row : rows) {
String[] fields = row.split(",");
for(String field : fields) {
System.out.printf("| %-5s", field);
}
System.out.println();
}
}
else{
Date startDate = dateFormat.parse(splited[2]);
Date endDate = dateFormat.parse(splited[3]);
String csv = stub.transaction_details(splited[1], startDate, endDate);
System.out.printf("| %-5s", "ID");
System.out.printf("| %-28s", "TIME");
System.out.printf("| %-5s", "AMOUNT");
System.out.printf("| %-5s", "BALANCE\n");
String[] rows = csv.split("\n");
for(String row : rows) {
String[] fields = row.split(",");
for(String field : fields) {
System.out.printf("| %-5s", field);
}
System.out.println();
}
}
}
}
}
catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}