This commit is contained in:
Simon SAYE BABU 2023-12-15 10:35:50 +01:00
parent b825103d79
commit f9fa89a97f
4 changed files with 18 additions and 5 deletions

View File

@ -28,14 +28,19 @@ public class Billet {
{ {
case Un: case Un:
output = 1; output = 1;
break;
case Cinq: case Cinq:
output = 5; output = 5;
break;
case Dix: case Dix:
output = 10; output = 10;
break;
/*case Vingt: /*case Vingt:
output = 20;*/ output = 20;
break;*/
default: default:
output = 0; output = 0;
break;
} }
return output; return output;
} }

View File

@ -3,8 +3,13 @@
* (Un billet peut avoir les valeurs suivantes Un, Cinq, Dix, Vingt) * (Un billet peut avoir les valeurs suivantes Un, Cinq, Dix, Vingt)
*/ */
public enum Denomination { public enum Denomination {
Un, Un (1),
Cinq, Cinq(5),
Dix; Dix(10);
//Vingt; //Vingt;
private int valeur;
private Denomination(int v)
{
this.valeur = v;
}
} }

View File

@ -38,7 +38,7 @@ public class Individu {
*/ */
public int getInt(){ public int getInt(){
int somme = 0; int somme = 0;
for (Billet billet : monnaie) { for (Billet billet : this.monnaie) {
somme += billet.getInt(); somme += billet.getInt();
} }
return somme; return somme;

View File

@ -18,6 +18,9 @@ public class Main {
Toto.addMonaie(new Billet(Denomination.Un)); Toto.addMonaie(new Billet(Denomination.Un));
Toto.addMonaie(new Billet(Denomination.Un)); Toto.addMonaie(new Billet(Denomination.Un));
System.out.println(Titi.getInt());
System.out.println(Toto.getInt());