DEV_BUT1/DEV2.1/CM1 (copy 1)/Exercice 2/Deduction2.java
2023-04-04 14:03:16 +02:00

39 lines
700 B
Java

//MELIANI SAMY (TP1)
public class Deduction2{
private int Limite, identifiant, Credit;
private int Accumulation;
public Deduction2(){
Limite = 10;
Accumulation=0;
Credit = 0;
identifiant = 253782;
}
public int voir(){
return Credit;
}
public void crediter(){
if (Credit < 10){
Credit += 1;
Accumulation += 1;
}
else{
Credit = 1;
Accumulation += 1;
}
}
public void vider(){
Credit = 0;
}
public String toString(){
String str = "";
str += "identifiant : " + identifiant + " ";
str += "Crédits restants : " + Credit + " ";
str += "Accumulation : " + Accumulation;
if(Credit == 10){
str+= " PLAT OFFERT ";
}
return str;
}
}