Académique Documents
Professionnel Documents
Culture Documents
catch(CloneNotSupportedException e){
System.err.println(e);
}
return c;
}
}
//Class Client *************************************
class Client {
protected String code;
protected String nom;
protected String adresse;
protected String tel;
protected Vector<Commande> listCommandes;
{
liste = liste + "\n "+listCommandes.get(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);
this.codeFidelite = codeFidelite;
this.tauxReduction = tauxReduction;
}
public String toString() {
return "ClientFidel : " + "codeFidelite=" + codeFidelite + ", tauxReduction=" + tauxReduction +
" "+ super.toString();
}
}
//programme main de test********************************
import java.util.*;
public class MainProg {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
Commande c1=new Commande(1,sdf.parse("26/01/2015"),"lait de lux");
Commande c2=new Commande(2,sdf.parse("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);
cl1.enregistrerCommande(c1);
cl1.enregistrerCommande(c2);
cl2.enregistrerCommande(c2);
cl2.enregistrerCommande(c2);
System.out.println(cl1);
System.out.println(cl2);
}
}