Update Configuration

Il manque isValid()
This commit is contained in:
Minh VU
2024-10-18 15:31:09 +02:00
parent 53edc969c5
commit ed03836ef4
5 changed files with 30 additions and 40 deletions

View File

@@ -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<PartType> 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<PartType> 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();;
}
}

View File

@@ -1,7 +0,0 @@
package src;
public class Engine extends PartType{
public Engine (String name){
super(name, E)
}
}

View File

@@ -1,5 +0,0 @@
package src;
public class Exterior extends PartType{
}

View File

@@ -1,9 +0,0 @@
package src;
public class Interior extends PartType{
public Interior (String name) {
this.super(name);
this.
}
}

View File

@@ -1,7 +0,0 @@
package src;
public class Transmission extends PartType{
public Transmission( String nom){
super (nom);
}
}