correction de selectPart, pour remplacer si une Part de la même catégorie est déjà présente
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user