-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompte.java
More file actions
50 lines (46 loc) · 1.06 KB
/
Compte.java
File metadata and controls
50 lines (46 loc) · 1.06 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
package src;
public class Compte<T> {
private int numeroCompte;
private double solde;
private T devise;
public Compte(int numeroCompte,double solde,T devise) {
this.devise=devise;
this.solde=solde;
this.numeroCompte=numeroCompte;
}
public void deposer(double montant) {
this.solde+=montant;
}
public void retirer(double montant) throws insuffisantsoldeexp {
if(this.solde>=montant) {
this.solde-=montant;
}
else {
throw new insuffisantsoldeexp("solde insuffisant");
}
}
public void afficherSolde() {
System.out.println("votre solde est: "+this.solde+this.devise);
}
public double getsolde() {
return this.solde;
}
public void setsolde(double solde) {
this.solde=solde;
}
public T getdevise() {
return this.devise;
}
public int getnumeroCompte() {
return this.numeroCompte;
}
public static <T extends Compte<T>> void transferer(T sender,T receiver, double montant) {
try {
sender.retirer(montant);
receiver.deposer(montant);
}
catch(insuffisantsoldeexp e) {
System.out.println("solde insuffisant");
}
}
}