Proterty color Interior + prix pour les Part
This commit is contained in:
@@ -1,11 +1,46 @@
|
||||
package src.fr.impl.Parts;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import src.fr.impl.CategoryImpl;
|
||||
import src.fr.impl.PartImpl;
|
||||
import src.fr.impl.PartTypeImpl;
|
||||
|
||||
public class Exterior extends PartImpl {
|
||||
public Exterior(String name, CategoryImpl category){
|
||||
super(new PartTypeImpl(name,Engine.class, category));
|
||||
public class Exterior extends PartImpl {
|
||||
|
||||
private static final Set<String> colorSet;
|
||||
static {
|
||||
colorSet = new HashSet<>();
|
||||
colorSet.add("white");
|
||||
colorSet.add("green");
|
||||
colorSet.add("red");
|
||||
colorSet.add("blue");
|
||||
colorSet.add("green");
|
||||
colorSet.add("gray");
|
||||
}
|
||||
|
||||
|
||||
public Exterior(String name, CategoryImpl category, int price){
|
||||
super(new PartTypeImpl(name,Engine.class, category),price);
|
||||
|
||||
Set<String> l = new HashSet<String>();
|
||||
l.add("red");
|
||||
this.addProperty("color", () -> getColor(), p -> setColor(p), colorSet);
|
||||
}
|
||||
|
||||
|
||||
public String getColor(){
|
||||
String result = "white";
|
||||
Optional<String> color = this.getProperty("color");
|
||||
if(color.isPresent()){
|
||||
result = color.get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setColor(String newColor){
|
||||
this.setProperty("color",newColor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user