I have a Java class that is something of the form:-
public class Angle
{
ANGLE_TYPE angleType;
ANGLE_TYPE defaultAngleType = ANGLE_TYPE.RAD;
enum ANGLE_TYPE
{
DEG, RAD, DEGMIN, DEGMINSEC;
}
}
The class has an 'enum' defined, as can be seen. My question regards the instance variable, 'defaultAngleType'. I want it to be the case so that this variable can only be assigned the values RAD or DEG, and to throw an error otherwise.
Any idea how to acheive this?