correction de selectPart, pour remplacer si une Part de la même catégorie est déjà présente

This commit is contained in:
trochas
2024-11-20 08:31:05 +01:00
parent cc920bf6b6
commit e6994a62b9

View File

@@ -65,11 +65,13 @@ public class ConfigurationImpl implements Configuration {
@Override
public void selectPart(PartType chosenPart) {
Category cat_chosenPart = chosenPart.getCategory();
Category category_chosenPart = chosenPart.getCategory();
//Vérifier s'il y a des pièces dans la même catégorie, si oui return
for(Part pt: selectedParts){
if(pt.getCategory().equals(cat_chosenPart)){
if(pt.getCategory().equals(category_chosenPart)){
System.out.println("Il y a une pièce dans la même catégorie dans la configuration");
selectedParts.remove(pt);
selectedParts.add(((PartTypeImpl)chosenPart).newInstance());
return;
}
}