42 lines
907 B
Java
42 lines
907 B
Java
package sudoku;
|
|
|
|
/**
|
|
* The enumeration type of all possible values of a Sudoku field.
|
|
*/
|
|
public enum Value {
|
|
ONE(1), TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9);
|
|
|
|
private final int id;
|
|
|
|
Value(int id) {
|
|
this.id = id;
|
|
}
|
|
|
|
/**
|
|
* Returns a string representation of this value. As a matter of fact, its id is returned.
|
|
*
|
|
* @return a string representation of this value.
|
|
*/
|
|
@Override
|
|
public String toString() {
|
|
return String.valueOf(id);
|
|
}
|
|
|
|
/**
|
|
* Returns the value with the specified id.
|
|
*
|
|
* @param id an id (1 <= id <= 9)
|
|
* @return the value with the specified id.
|
|
*/
|
|
public static Value of(int id) {
|
|
return values()[id - 1];
|
|
}
|
|
|
|
/**
|
|
* Returns the id of this instance.
|
|
*
|
|
* @return the id of this instance.
|
|
*/
|
|
public int getId() {return id;}
|
|
}
|