getprixtotal pour config

This commit is contained in:
Minh VU
2024-12-04 16:50:28 +01:00
parent f9c6059067
commit 6ca58a33f6
2 changed files with 37 additions and 28 deletions

View File

@@ -201,6 +201,4 @@ public class CompatibilityManagerImpl implements CompatibilityManager {
Femeture_Transivite(reference, result,new HashSet<>(),reference); Femeture_Transivite(reference, result,new HashSet<>(),reference);
return result; return result;
} }
} }

View File

@@ -17,39 +17,50 @@ public class ConfigurationImpl implements Configuration {
@Override @Override
public boolean isValid() { public boolean isValid() {
if (this.isComplete()){ for(Part pt: selectedParts){
for(Part pt: selectedParts){ //Verifier Requirements
//Verifier Requirements for(PartType require : compatibilityManager.getRequirements(pt.getType())){
for(PartType require : compatibilityManager.getRequirements(pt.getType())){ //if(!selectedParts.contains(require)) return false;
//if(!selectedParts.contains(require)) return false; //IN V2, instead of verify if it's in selectedParts,
//IN V2, instead of verify if it's in selectedParts, //we will compare its type and selectedParts
//we will compare its type and selectedParts //boolean no_error = true;
//boolean no_error = true;
for(Part selectPart : selectedParts){ for(Part selectPart : selectedParts){
if (selectPart.getType().equals(require)){ if (selectPart.getType().equals(require)){
return false; return false;
//no_error= true; //no_error= true;
//break; //break;
}
}
}
//Verifier Incompabilities
for(PartType incompa : compatibilityManager.getIncompatibilities(pt.getType())){
for (Part selectPart : selectedParts){
if(selectPart.getType().equals(incompa)){
return false;
}
} }
} }
} }
return true; //Verifier Incompabilities
for(PartType incompa : compatibilityManager.getIncompatibilities(pt.getType())){
for (Part selectPart : selectedParts){
if(selectPart.getType().equals(incompa)){
return false;
}
}
}
}
return true;
}
public int getPriceTotal(){
int prix_final=0;
if(this.isValid()){
for(Part pt: selectedParts){
Optional<String> price_opt =pt.getProperty("prix");
if(price_opt.isPresent()){
int prix_piece= Integer.parseInt(price_opt.get());
prix_final += prix_piece;
}
}
return prix_final;
}else{ }else{
return false; return -1;
} }
} }
@Override @Override
public boolean isComplete() { public boolean isComplete() {
if(selectedParts.size()==NB_CATEGORY){ if(selectedParts.size()==NB_CATEGORY){