42 lines
982 B
Java
42 lines
982 B
Java
package banque;
|
|
|
|
import java.util.*;
|
|
|
|
public class Operation {
|
|
private int numero;
|
|
private Date dateOperation;
|
|
private double montant;
|
|
|
|
// Constructeur
|
|
Operation(double montant) {
|
|
this.numero = 0;
|
|
this.dateOperation = new Date();
|
|
this.montant = montant;
|
|
}
|
|
|
|
// Getters et Setters
|
|
public int getNumero() {
|
|
return this.numero;
|
|
}
|
|
public double getMontant() {
|
|
return montant;
|
|
}
|
|
public void setNumero(int numero) {
|
|
this.numero = numero;
|
|
}
|
|
|
|
// Méthodes de la classe
|
|
public String toString() {
|
|
String type;
|
|
if (Retrait.class.isInstance(this)) {
|
|
type = "Retrait";
|
|
}
|
|
else if (Versement.class.isInstance(this)) {
|
|
type = "Versement";
|
|
}
|
|
else {
|
|
throw new RuntimeException();
|
|
}
|
|
return this.getNumero() + ". " + this.dateOperation.toString() + ": " + type + " de " + this.montant;
|
|
}
|
|
}
|