I might be doing this wrong, but I am trying to enumate all the graphics mechanisms in Java with the enum operator:
enum GRAPHIC_MODES {
NULL=E_DRIVER_TYPE.EDT_NULL,
SOFTWARE=E_DRIVER_TYPE.EDT_SOFTWARE, OPENGL=E_DRIVER_TYPE.EDT_OPENGL, DX8=E_DRIVER_TYPE.EDT_DIRECTX8, DX9=E_DRIVER_TYPE.EDT_DIRECTX9 }
When compiling I keep getting error thats I am missing a brace and every enum example I see doesn't have a terminating operator and I am probably doing this all wrong. Any help is appreciated.
Question about Java Enums
You can not do what you want with enums in Java.
enums are used for enumnarations(like the name Say) but imho intern they are alway count from zero.
public enum MyEnum
{
zero, one, two, three
}
public enum MyEnum2
{
green, red, blue
}
Internaly:
green = 0
red = 1
blue = 2
You could write a enum and a class that will do this
something like...
public enum GRAPHIC_MODES
{
NULL ,
SOFTWARE,
OPENGL,
DX8,
DX9
}
public class MyGRAPHIC_MODES
{
public static Object getMode(GRAPHIC_MODES mode)
{
Object retObj = null;
switch(mode)
{
case GRAPHIC_MODES.NULL:
retObj = E_DRIVER_TYPE.EDT_NULL;
break;
case GRAPHIC_MODES.SOFTWARE:
retObj = E_DRIVER_TYPE.EDT_SOFTWARE;
break;
case GRAPHIC_MODES.OPENGL
retObj = E_DRIVER_TYPE.EDT_OPENGL;
break;
case GRAPHIC_MODES.DX8:
retObj = E_DRIVER_TYPE.EDT_DIRECTX8;
break;
case GRAPHIC_MODES.DX9:
retObj = E_DRIVER_TYPE.EDT_DIRECTX9 ;
break;
return retObj;
}
then you can get your mode with
... = MyGRAPHIC_MODES.getMode(GRAPHIC_MODES.DX8);
enums are used for enumnarations(like the name Say) but imho intern they are alway count from zero.
public enum MyEnum
{
zero, one, two, three
}
public enum MyEnum2
{
green, red, blue
}
Internaly:
green = 0
red = 1
blue = 2
You could write a enum and a class that will do this
something like...
public enum GRAPHIC_MODES
{
NULL ,
SOFTWARE,
OPENGL,
DX8,
DX9
}
public class MyGRAPHIC_MODES
{
public static Object getMode(GRAPHIC_MODES mode)
{
Object retObj = null;
switch(mode)
{
case GRAPHIC_MODES.NULL:
retObj = E_DRIVER_TYPE.EDT_NULL;
break;
case GRAPHIC_MODES.SOFTWARE:
retObj = E_DRIVER_TYPE.EDT_SOFTWARE;
break;
case GRAPHIC_MODES.OPENGL
retObj = E_DRIVER_TYPE.EDT_OPENGL;
break;
case GRAPHIC_MODES.DX8:
retObj = E_DRIVER_TYPE.EDT_DIRECTX8;
break;
case GRAPHIC_MODES.DX9:
retObj = E_DRIVER_TYPE.EDT_DIRECTX9 ;
break;
return retObj;
}
then you can get your mode with
... = MyGRAPHIC_MODES.getMode(GRAPHIC_MODES.DX8);