Update Configuration
Il manque isValid()
This commit is contained in:
@@ -3,59 +3,77 @@ package src;
|
|||||||
import fr.istic.nplouzeau.cartaylor.api.Category;
|
import fr.istic.nplouzeau.cartaylor.api.Category;
|
||||||
import fr.istic.nplouzeau.cartaylor.api.PartType;
|
import fr.istic.nplouzeau.cartaylor.api.PartType;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Configuration implements fr.istic.nplouzeau.cartaylor.api.Configuration {
|
public class Configuration implements fr.istic.nplouzeau.cartaylor.api.Configuration {
|
||||||
private Engine e;
|
private Set<PartType> selectedParts;
|
||||||
private Exterior ex;
|
|
||||||
private Interior in;
|
|
||||||
private Transmission tr;
|
|
||||||
|
|
||||||
private CompatibilityManager compatibilityManager;
|
private CompatibilityManager compatibilityManager;
|
||||||
private
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if ( this.isComplete()){
|
if ( this.isComplete()){
|
||||||
//TODO
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isComplete() {
|
public boolean isComplete() {
|
||||||
|
if(selectedParts.size()==4){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PartType> getSelectedParts() {
|
public Set<PartType> getSelectedParts() {
|
||||||
return Set.of();
|
return selectedParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPart(PartType chosenPart) {
|
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
|
@Override
|
||||||
public PartType getSelectionForCategory(Category category) {
|
public PartType getSelectionForCategory(Category category) {
|
||||||
|
for( PartType pt: selectedParts){
|
||||||
|
if(pt.getCategory().equals(category)){
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unselectPartType(Category categoryToClear) {
|
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
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
this.selectedParts.clear();;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package src;
|
|
||||||
public class Engine extends PartType{
|
|
||||||
public Engine (String name){
|
|
||||||
super(name, E)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package src;
|
|
||||||
|
|
||||||
public class Exterior extends PartType{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package src;
|
|
||||||
public class Interior extends PartType{
|
|
||||||
public Interior (String name) {
|
|
||||||
this.super(name);
|
|
||||||
this.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package src;
|
|
||||||
|
|
||||||
public class Transmission extends PartType{
|
|
||||||
public Transmission( String nom){
|
|
||||||
super (nom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user