import java.io.*; import java.util.Random; public class testP3 { static Random rand = new Random(); enum Weekday { Mon(rand.nextInt()), Tue(rand.nextInt()), Wed(rand.nextInt()), Thu(rand.nextInt()), Fri(rand.nextInt()), Sat(rand.nextInt()), Sun(rand.nextInt()); // must appear first private int day; private Weekday( int d ) { day = d; } public boolean isWeekday() { return day <= Fri.day; } public boolean isWeekend() { return Fri.day < (int)day; } } public static void main( String[] args ) { Weekday day = Weekday.Sat; System.out.println( day.ordinal() + " " + day.day + " " + day.name() ); for ( Weekday iday : day.values() ) { System.out.print( iday.ordinal() + " " + iday.day + " " + iday.name() + ", " ); } System.out.println(); System.out.println( day.isWeekday() ); // false System.out.println( day.isWeekend() ); // true Weekday day2 = Weekday.Sat; System.out.println( day2.ordinal() + " " + day2.day + " " + day2.name() ); for ( Weekday iday : day2.values() ) { System.out.print( iday.ordinal() + " " + iday.day + " " + iday.name() + ", " ); } System.out.println(); System.out.println( day2.isWeekday() ); // false System.out.println( day2.isWeekend() ); // true } } // java test