Vote count:
0
Each color has its own static attribute - a number. I want to be able to change this value with a method. Can I do this using enums somehow? Like this or perhaps differently:
public enum Color {
RED, ORANGE, YELLOW;
}
Color.RED.setValue(x);
Color.RED.getValue();
Or would I have to do something like this where color is a class?
public Red extends Color {
private static int x;
public int getRedValue(){
return x;
}
public void setRedValue(int x){
this.x = x;
}
}
asked 37 secs ago
Enums with attributes Java
Aucun commentaire:
Enregistrer un commentaire