-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientBanque.java
95 lines (83 loc) · 3 KB
/
ClientBanque.java
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
/*
* ABDELHAKIM KHAOUITI
* 20 SEP 2024
*/
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import java.util.Scanner;
public class ClientBanque {
public static void main(String[] args) {
Properties props = System.getProperties();
int status;
ORB orb = null;
try {
orb = ORB.init(args, props);
status = run(orb);
} catch (Exception ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (Exception ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
static int run(ORB orb) throws IOException {
Object obj;
String refFile = "reference";
try (FileInputStream file = new FileInputStream(refFile);
BufferedReader in = new BufferedReader(new InputStreamReader(file))) {
String ref = in.readLine();
obj = orb.string_to_object(ref);
Compte compte = CompteHelper.narrow(obj);
int choice;
double amount = 0.0;
Scanner scanner = new Scanner(System.in);
// Display menu
System.out.println("+---------------------------+");
System.out.println("| Service bancaire |");
System.out.println("+---------------------------+");
System.out.println("1 : Lecture du montant du compte");
System.out.println("2 : Crédit du compte");
System.out.println("3 : Débit du compte");
System.out.println("0 : Quitter");
do {
choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("Lecture du montant du compte");
System.out.println(compte.solde());
break;
case 2:
System.out.println("Crédit du compte");
System.out.println("Taper le montant: ");
amount = scanner.nextDouble();
System.out.println(compte.credit(amount));
break;
case 3:
System.out.println("Débit du compte");
System.out.println("Taper le montant: ");
amount = scanner.nextDouble();
System.out.println(compte.debit(amount));
break;
case 0:
System.out.println("Quitter");
break;
default:
System.out.println("Choix invalide, veuillez réessayer.");
}
} while (choice != 0);
}
return 0;
}
}