PIbd-22-Stroev-V.M.-Monorai.../CountWheels.java
2023-12-05 17:24:43 +04:00

25 lines
575 B
Java

public enum CountWheels{
Min(2),
Mid(3),
Max(4);
private final int val;
private CountWheels(int val){
this.val = val;
}
public int getCountWheels(){
return val;
}
public static CountWheels fromNumberToEnum(int number) {
try{
for (CountWheels countWheels : CountWheels.values()) {
if (countWheels.getCountWheels() == number) {
return countWheels;
}
}
}catch(NumberFormatException e){
}
return Min;
}
}