100% ont trouvé ce document utile (1 vote)
193 vues3 pages

Correction POOMai 13

Le document présente la correction d'un examen national de BTS DSI sur la programmation orientée objet. Il définit les classes Commande, Client et ClientFidel avec leurs attributs et méthodes ainsi qu'un programme principal pour tester ces classes.

Transféré par

Hathat
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
100% ont trouvé ce document utile (1 vote)
193 vues3 pages

Correction POOMai 13

Le document présente la correction d'un examen national de BTS DSI sur la programmation orientée objet. Il définit les classes Commande, Client et ClientFidel avec leurs attributs et méthodes ainsi qu'un programme principal pour tester ces classes.

Transféré par

Hathat
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Correction d’examen National du BTS DSI session Mai 2013 Partie 1 POO

// classe Commande ***************************************


class Commande implements Cloneable {
private int numCom;
private Date dateCom;
private String nomFournisseur;

public Commande(int numCom, Date dateCom, String nomFournisseur) {


[Link] = numCom;
[Link] = dateCom;
[Link] = nomFournisseur;
}
public String toString() {
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
return numCom + " , date :" + [Link](dateCom) + ", Fournisseur: " + nomFournisseur ;
}
public boolean equals(Object obj) {
Commande c = (Commande) obj;
if ([Link] != [Link]) {
return false;
}
return true;
}
public int getNumCom() {
return numCom;
}
public Date getDateCom() {
return dateCom;
}
public String getNomFournisseur() {
return nomFournisseur;
}
public void setNumCom(int numCom) {
[Link] = numCom;
}
public void setDateCom(Date dateCom) {
[Link] = dateCom;
}
public void setNomFournisseur(String nomFournisseur) {
[Link] = nomFournisseur;
}
protected Commande clone() {
Commande c=null;
try{
c=(Commande) [Link]();
}

Correction proposée par Pr [Link] Page 1 sur 3


Correction d’examen National du BTS DSI session Mai 2013 Partie 1 POO

catch(CloneNotSupportedException e){
[Link](e);
}
return c;
}
}
//Class Client *************************************
class Client {
protected String code;
protected String nom;
protected String adresse;
protected String tel;
protected Vector<Commande> listCommandes;

public Client(String code, String nom, String adresse) {


[Link] = code;
[Link] = nom;
[Link] = adresse;
listCommandes=new Vector<Commande>();
}
public boolean enregistrerCommande (Commande cmd)
{
if(![Link](cmd)) {
[Link](cmd);
return true;
}
return false;
}

public boolean supprimerCommande (int position)


{
for (int i=0;i<[Link]();i++)
{
if([Link](i).getNumCom()==position)
{
[Link](i);
return true;
}
}
return false;
}

public String toString() {


String liste="";
for (int i=0;i<[Link]();i++)

Correction proposée par Pr [Link] Page 2 sur 3


Correction d’examen National du BTS DSI session Mai 2013 Partie 1 POO

{
liste = liste + "\n "+[Link](i);
}
return "Client : " + "code=" + code + ", nom=" + nom + ", adresse=" + adresse +" \n la liste des
Commandes: "+ liste+".";
}

}
//Class ClientFidel******************************************
class ClientFidel extends Client{
String codeFidelite ;
float tauxReduction ;

public ClientFidel( String code, String nom, String adresse,String codeFidelite, float
tauxReduction) {
super(code, nom, adresse);
[Link] = codeFidelite;
[Link] = tauxReduction;
}
public String toString() {
return "ClientFidel : " + "codeFidelite=" + codeFidelite + ", tauxReduction=" + tauxReduction +
" "+ [Link]();
}

}
//programme main de test********************************
import [Link].*;
public class MainProg {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
Commande c1=new Commande(1,[Link]("26/01/2015"),"lait de lux");
Commande c2=new Commande(2,[Link]("09/03/2015"),"infomat");
Client cl1 =new Client("C1","mohammed","App 33 N 4 hay elkassam laayoune");
ClientFidel cl2 =new ClientFidel("C2","khadija","App 12 N 12 CYM rabat","F2",10.3f);
[Link](c1);
[Link](c2);
[Link](c2);
[Link](c2);
[Link](cl1);
[Link](cl2);
}
}

Correction proposée par Pr [Link] Page 3 sur 3

Vous aimerez peut-être aussi