push
This commit is contained in:
36
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction.java
Normal file
36
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction.java
Normal file
@@ -0,0 +1,36 @@
|
||||
//MELIANI SAMY (TP1)
|
||||
public class Deduction{
|
||||
public static void main(String[] args) {
|
||||
Deduction2 compte = new Deduction2();
|
||||
compte.voir();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.vider();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
compte.crediter();
|
||||
System.out.println(compte.toString());
|
||||
|
||||
Deduction3 compte2 = new Deduction3();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
compte2.crediter();
|
||||
System.out.println(compte2.toString());
|
||||
}
|
||||
}
|
||||
39
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction2.java
Normal file
39
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction2.java
Normal file
@@ -0,0 +1,39 @@
|
||||
//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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction3.java
Normal file
30
DEV2.1/CM1 (copy 1)/Exercice 2/Deduction3.java
Normal file
@@ -0,0 +1,30 @@
|
||||
//MELIANI SAMY (TP1)
|
||||
public class Deduction3{
|
||||
private int Limite, identifiant, Credit;
|
||||
private int Accumulation;
|
||||
public Deduction3(){
|
||||
Limite = 10;
|
||||
Accumulation=0;
|
||||
Credit = 10;
|
||||
identifiant = 253782;
|
||||
}
|
||||
public int voir(){
|
||||
return Credit;
|
||||
}
|
||||
public void crediter(){
|
||||
Accumulation += 1;
|
||||
}
|
||||
public void vider(){
|
||||
Credit = 10;
|
||||
}
|
||||
public String toString(){
|
||||
String str = "";
|
||||
str += "YesCard USER ";
|
||||
str += "identifiant : " + identifiant + " ";
|
||||
str += "Crédits restants : " + Credit + " ";
|
||||
str += "Accumulation : " + Accumulation;
|
||||
str+= " PLAT OFFERT ";
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user