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);
return result;
}
}

View File

@@ -17,39 +17,50 @@ public class ConfigurationImpl implements Configuration {
@Override
public boolean isValid() {
if (this.isComplete()){
for(Part pt: selectedParts){
//Verifier Requirements
for(PartType require : compatibilityManager.getRequirements(pt.getType())){
//if(!selectedParts.contains(require)) return false;
//IN V2, instead of verify if it's in selectedParts,
//we will compare its type and selectedParts
//boolean no_error = true;
for(Part pt: selectedParts){
//Verifier Requirements
for(PartType require : compatibilityManager.getRequirements(pt.getType())){
//if(!selectedParts.contains(require)) return false;
//IN V2, instead of verify if it's in selectedParts,
//we will compare its type and selectedParts
//boolean no_error = true;
for(Part selectPart : selectedParts){
if (selectPart.getType().equals(require)){
return false;
//no_error= true;
//break;
}
}
}
//Verifier Incompabilities
for(PartType incompa : compatibilityManager.getIncompatibilities(pt.getType())){
for (Part selectPart : selectedParts){
if(selectPart.getType().equals(incompa)){
return false;
}
for(Part selectPart : selectedParts){
if (selectPart.getType().equals(require)){
return false;
//no_error= true;
//break;
}
}
}
}
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{
return false;
return -1;
}
}
@Override
public boolean isComplete() {
if(selectedParts.size()==NB_CATEGORY){