diff --git a/src/Configuration.java b/src/Configuration.java index ca5f784..26224c3 100644 --- a/src/Configuration.java +++ b/src/Configuration.java @@ -3,59 +3,77 @@ package src; import fr.istic.nplouzeau.cartaylor.api.Category; import fr.istic.nplouzeau.cartaylor.api.PartType; + import java.util.Set; public class Configuration implements fr.istic.nplouzeau.cartaylor.api.Configuration { - private Engine e; - private Exterior ex; - private Interior in; - private Transmission tr; - + private Set selectedParts; private CompatibilityManager compatibilityManager; - private + @Override public boolean isValid() { if ( this.isComplete()){ - //TODO + return true; } else{ return false; } - - return false; } @Override public boolean isComplete() { + if(selectedParts.size()==4){ + return true; + } return false; } @Override public Set getSelectedParts() { - return Set.of(); + return selectedParts; } @Override public void selectPart(PartType chosenPart) { - + Category cat_chosenPart = chosenPart.getCategory(); + + //Vérifier s'il y a des pièces dans la même catégorie, si oui return + for( PartType pt: selectedParts){ + if(pt.getCategory().equals(cat_chosenPart)){ + System.out.println("Il y a une pièce dans la même catégorie dans la configuration"); + return; + } + } + selectedParts.add(chosenPart); } @Override public PartType getSelectionForCategory(Category category) { + for( PartType pt: selectedParts){ + if(pt.getCategory().equals(category)){ + return pt; + } + } return null; } @Override public void unselectPartType(Category categoryToClear) { + for( PartType pt: selectedParts){ + if(pt.getCategory().equals(categoryToClear)){ + selectedParts.remove(pt); + } + } + System.out.println("Il n'y a pas des pièces dans cette catégorie"); } @Override public void clear() { - + this.selectedParts.clear();; } } diff --git a/src/Engine.java b/src/Engine.java deleted file mode 100644 index aaede7a..0000000 --- a/src/Engine.java +++ /dev/null @@ -1,7 +0,0 @@ -package src; -public class Engine extends PartType{ - public Engine (String name){ - super(name, E) - } - -} \ No newline at end of file diff --git a/src/Exterior.java b/src/Exterior.java deleted file mode 100644 index 8b709e7..0000000 --- a/src/Exterior.java +++ /dev/null @@ -1,5 +0,0 @@ -package src; - -public class Exterior extends PartType{ - -} diff --git a/src/Interior.java b/src/Interior.java deleted file mode 100644 index 55a5eae..0000000 --- a/src/Interior.java +++ /dev/null @@ -1,9 +0,0 @@ -package src; -public class Interior extends PartType{ - public Interior (String name) { - this.super(name); - this. - - } - -} \ No newline at end of file diff --git a/src/Transmission.java b/src/Transmission.java deleted file mode 100644 index 0a75ee5..0000000 --- a/src/Transmission.java +++ /dev/null @@ -1,7 +0,0 @@ -package src; - -public class Transmission extends PartType{ - public Transmission( String nom){ - super (nom); - } -} \ No newline at end of file