//Magasin
public class Magasin {
int id;
String adress;
String capacite;
Produit[] produit_Tab = new Produit[50];
public Magasin(int id, String adress, String capacite) {
[Link] = id;
[Link] = adress;
[Link] = capacite;
}
int i = 0;
public void ajouter_produit(Produit produit) {
if (produit_Tab.length
<50) {
this.produit_Tab[i] = produit;
i++;
}else{
[Link]("pas de capacite ");
}
}
public void afficher(){
[Link]([Link] + [Link] + [Link]);
for (int i=0 ; i< produit_Tab.length;i++){
[Link](produit_Tab[i]);
}
}
// produit
class Produit {
public void afficher(){
[Link]("l'id du produit est "+id+"\n libelle du produit est
"+libelle+"\n la marque du produit est "+marque+"\n le prix du produit est
"+prix+"\nla date d'expiration est "+date_expir);
}
protected int id ;
protected String libelle ;
protected String marque ;
protected float prix ;
LocalDate date_expir ;
public Produit() {
}
public Produit(int id, String libelle, String marque , float prix) {
[Link] = prix ;
[Link] = id ;
[Link]= libelle;
[Link] = marque;
}
public Produit(int id , String libelle , String marque){
[Link] = id ;
[Link]= libelle;
[Link] = marque;
}
}
// main
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {
// Press Alt+Enter with your caret at the highlighted text to see how
// IntelliJ IDEA suggests fixing it.
Produit p0 = new Produit();
Produit p1= new Produit(1021,"Lait","delice");
Produit p2= new Produit(2510,"Yaourt","Vitalait");
Produit p3= new Produit(3510,"Tomate","Sicam", 1.200F);
[Link](p1);
[Link]();
[Link]();
[Link]();
[Link] = 0.700F;
[Link]();
[Link] = 1.00F;
[Link]();
[Link]("Affichage avec methode toString "+[Link]());
//affiche l'adresse
p1.date_expir = [Link](2023,12,12);
p2.date_expir = [Link](2024,1,10);
p3.date_expir = [Link](2025,6,1);
[Link]();
[Link]();
[Link]();
}
}