2023-12-18 21:05:47 +01:00
|
|
|
/**
|
|
|
|
* cette classe represente un billet de banque
|
|
|
|
*/
|
2023-12-01 14:24:23 +01:00
|
|
|
public class Billet{
|
2023-12-18 21:05:47 +01:00
|
|
|
/**
|
|
|
|
* Valeur du billet
|
|
|
|
*/
|
2023-12-01 14:24:23 +01:00
|
|
|
private Denomination valeur;
|
|
|
|
|
2023-12-18 21:05:47 +01:00
|
|
|
/**
|
|
|
|
* Creer un billet
|
|
|
|
* @param valeur valeur du billet
|
|
|
|
*/
|
2023-12-01 14:24:23 +01:00
|
|
|
public Billet(Denomination valeur){
|
|
|
|
this.valeur = valeur;
|
|
|
|
}
|
|
|
|
|
2023-12-18 21:05:47 +01:00
|
|
|
/**
|
|
|
|
* donne la valeur du billet
|
|
|
|
* @return montant du billet
|
|
|
|
*/
|
2023-12-01 14:24:23 +01:00
|
|
|
public int getValeur(){
|
|
|
|
if (valeur == Denomination.UN){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.DEUX){
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.CINQ){
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.DIX){
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.VINGT){
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.CINQUANTE){
|
|
|
|
return 50;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.CENT){
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.DEUX_CENT){
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
if (valeur == Denomination.CINQ_CENT){
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2023-12-18 21:05:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* compare 2 billets en fonction de leurs valeurs
|
|
|
|
* @param billet billet a comparer
|
|
|
|
* @return true si les 2 billets ont les memes valeurs / false sinon
|
|
|
|
*/
|
|
|
|
public boolean equals(Billet billet){
|
|
|
|
if (this.getValeur() == billet.getValeur()){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2023-12-01 14:24:23 +01:00
|
|
|
}
|