Hello dear programmers,
I want to choose enum's randomly, like this:
I know so far, that I can't cast integers to specific enum types, but is there an easier way? Can I get the possible values of that enum type?
static enum test{e1, e2, e3}; public test randomEnumPicker(){ int random = Greenfoot.getRandomNumber(3); if(random == 0) return e1; else if(random == 1) return e2; else if(random == 2) return e3; }