Académique Documents
Professionnel Documents
Culture Documents
Code source
classe membre :
// Constructeur
public Membre(int ID, String nom, Groupe groupe, String projet_en_cours) { this.ID = ID;
this.nom = nom; this.groupe = groupe;
this.projet_en_cours = projet_en_cours;
}
// Constructeur public
Groupe(int ID) {
this.ID = ID;
this.membres = new HashSet<>();
}
// Constructeur
public Partenariat(Groupe groupe1, Groupe groupe2) { this.groupe1 =
groupe1; this.groupe2 = groupe2;
}
if (groupes.size() >= 2) {
Partenariat partenariat = new Partenariat(groupes.get(0),
groupes.get(1)); partenariats.add(partenariat);
}
}
if (membreASupprimer != null) {
membres.remove(membreASupprimer);
}
}
Membre membre1 = new Membre(1, "John Doe", groupe1, "Projet A"); Membre membre2 = new
Membre(2, "Jane Doe", groupe2, "Projet B");
laboratoire.membres.add(membre1); laboratoire.membres.add(membre2);
Classe Produit :
package Tp4;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public ProduitEx3(String id ,String nom ,double prix,String categorie ,int anneFabric, Set<Integer>
set ) {
this.id = id;
this.nom = nom;
this.prix = prix;
this.categorie = categorie;
this.anneFabric = anneFabric;
this.evaluations.addAll(set);
}
@Override
public String toString() {
return "Produit [id=" + id + ", nom = " + nom + ", prix = " + prix + ", anneFabric = " +
anneFabric + "]";
}
}
Fonction main :
package Tp4;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
ProduitEx3 produit2 = new ProduitEx3("002", "Chaise", 49.99, "Meuble", 2020, Set.of(4, 4, 5));
ProduitEx3 produit3 = new ProduitEx3("003", "Livre", 14.99, "Librairie", 2021, Set.of(5, 5, 4));
produits.add(produit1);
produits.add(produit2);
produits.add(produit3);
// Stream 1
.map(p -> {
})
.collect(Collectors.toSet());
// Stream 2
.map(p -> {
})
.collect(Collectors.toSet());
// Stream 3