30 lines
803 B
Java
30 lines
803 B
Java
|
public enum CountWheels{
|
||
|
Min(2),
|
||
|
Mid(3),
|
||
|
Max(4);
|
||
|
private final int val;
|
||
|
private CountWheels(int val){
|
||
|
this.val = val;
|
||
|
}
|
||
|
private int countWheels;
|
||
|
public int getCountWheels(){
|
||
|
return val;
|
||
|
}
|
||
|
public void setCountWheels(int countWheels){
|
||
|
this.countWheels = countWheels;
|
||
|
}
|
||
|
public void setEnumValue(){
|
||
|
CountWheels enumvalue = CountWheels.values()[countWheels];
|
||
|
}
|
||
|
public static CountWheels fromNumberToEnum(int number) {
|
||
|
try{
|
||
|
for (CountWheels countWheels : CountWheels.values()) {
|
||
|
if (countWheels.getCountWheels() == number) {
|
||
|
return countWheels;
|
||
|
}
|
||
|
}
|
||
|
}catch(NumberFormatException e){
|
||
|
}
|
||
|
return Min;
|
||
|
}
|
||
|
}
|