Correction d’examen National du BTS DSI session Mai 2013 : JAVA
- Classe Client :
import java.util.Vector;
public class Client {
protected String CodeClient;
protected String NomClient;
protected String AdrClient;
protected String TelClient;
static boolean a;
static String msg;
public Vector<Commande> listCommandes;
public Client(String C,String N,String A){
CodeClient=C;
NomClient=N;
AdrClient=A;
listCommandes=new Vector<Commande>();
}
public void EnregidterCommande(Commande c){
listCommandes.add(c);
}
public boolean SupprimerCommande(int Num){
for(int i=0;i<listCommandes.size();i++){
if(Num==listCommandes.elementAt(i). getNumCommande()){
listCommandes.removeElementAt(i);
a=true;
}
else
a=false;
}
return a;
}
public String toString() {
msg="Client{CodeClient=" + CodeClient + ", NomClient=" + NomClient + ", AdrClient=" + AdrClient + ", TelClient=" + TelClient + ", listCommandes=";
for(Commande c:listCommandes){
msg+=c;
}
return msg;
}
}
package exam_java_2013;
public class ClientFidel extends Client{
private String CodeFidelite;
private float TauxReducttion;
public ClientFidel(String C,String N,String A,String Cod,float TR){
super(C,N,A);
CodeFidelite=Cod;
TauxReducttion=TR;
}
public String toString() {
return super.toString()+"ClientFidel{" + "CodeFidelite=" + CodeFidelite + ", TauxReducttion=" + TauxReducttion + '}';
}
}
- Classe Commande :
package exam_java_2013;
import java.util.Date;
public class Commande {
private int NumCommande;
private Date DateCommande;
private String NomFournisseur;
public Date getDateCommande() {
return DateCommande;
}
public void setDateCommande(Date DateCommande) {
this.DateCommande = DateCommande;
}
public String getNomFournisseur() {
return NomFournisseur;
}
public void setNomFournisseur(String NomFournisseur) {
this.NomFournisseur = NomFournisseur;
}
public int getNumCommande() {
return NumCommande;
}
public void setNumCommande(int NumCommande) {
this.NumCommande = NumCommande;
}
public Commande(int NumCommande, Date DateCommande, String NomFournisseur) {
this.NumCommande = NumCommande;
this.DateCommande = DateCommande;
this.NomFournisseur = NomFournisseur;
}
public String toString() {
return "NumCommande=" + NumCommande + ", DateCommande=" + DateCommande + ", NomFournisseur=" + NomFournisseur ;
}
public boolean equals(Object obj){
Commande c= (Commande)obj;
if(NumCommande==c.getNumCommande()){
return true;
}
else
return false;
}
}
- Classe Test :
package exam_java_2013;
import java.util.Date;
public class Test {
public static void main(String[] args){
Commande c1=new Commande(1,new Date(12/03/2014),"Safa");
Commande c2=new Commande(2,new Date(12/02/2015),"Sousou");
Client clt1=new Client("A1","medo","Rue Zriouilla");
ClientFidel cf=new ClientFidel("B2","maya","hay Alqodss","067DCT",400);
clt1.EnregidterCommande(c1);
cf.EnregidterCommande(c2);
cf.EnregidterCommande(c1);
System.out.println(cf.SupprimerCommande(2));
System.out.println(cf);
System.out.println(clt1);
System.out.println(cf);
}
}
Commentaires
Enregistrer un commentaire