Files
cartailor/src/fr/impl/Parts/Exterior.java
2024-12-20 11:00:53 +01:00

60 lines
1.4 KiB
Java

package src.fr.impl.Parts;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import src.fr.api.PartType;
import src.fr.impl.PartImpl;
public class Exterior extends PartImpl {
private static final HashMap<String,Integer> prices;
static {
prices = new HashMap<>();
prices.put("XC",0);
prices.put("XM",800);
prices.put("XS",10000);
}
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");
}
private String color;
/*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(), c -> setColor(c), colorSet);
}*/
public Exterior(){
this.addProperty("color", () -> getColor(), c -> setColor(c), colorSet);
}
public String getColor(){
return this.color;
}
public void setColor(String newColor){
this.color = newColor;
}
@Override
public void setType(PartType type){
this.type = type;
this.price = prices.get(type.getName());
}
}