fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.lang.reflect.InvocationTargetException;
  8. import java.util.concurrent.ThreadLocalRandom;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. List < Class > classes = List.of( Beach.class , CandyLand.class , Forest.class , Frozen.class , Space.class );
  16. int index = ThreadLocalRandom.current().nextInt( 0 , classes.size() ); // Half-open: origin is inclusive while the bound is exclusive.
  17. Class < Arena > c = classes.get( index );
  18. Arena arena = null;
  19. try
  20. {
  21. arena = c.getDeclaredConstructor().newInstance();
  22. } catch ( InstantiationException e )
  23. {
  24. e.printStackTrace();
  25. } catch ( IllegalAccessException e )
  26. {
  27. e.printStackTrace();
  28. {
  29. e.printStackTrace();
  30. } catch ( NoSuchMethodException e )
  31. {
  32. e.printStackTrace();
  33. }
  34.  
  35. System.out.println( "BASIL - Done." );
  36. }
  37. }
  38.  
  39. interface Arena
  40. {
  41. }
  42.  
  43. class Beach implements Arena
  44. {
  45. public Beach ( )
  46. {
  47. System.out.println( "BASIL - Constructing Beach. " );
  48. }
  49. }
  50.  
  51. class CandyLand implements Arena
  52. {
  53. public CandyLand ( )
  54. {
  55. System.out.println( "BASIL - Constructing CandyLand. " );
  56. }
  57. }
  58.  
  59.  
  60. class Forest implements Arena
  61. {
  62. public Forest ( )
  63. {
  64. System.out.println( "BASIL - Constructing Forest. " );
  65. }
  66. }
  67.  
  68. class Frozen implements Arena
  69. {
  70. public Frozen ( )
  71. {
  72. System.out.println( "BASIL - Constructing Frozen. " );
  73. }
  74. }
  75.  
  76. class Space implements Arena
  77. {
  78. public Space ( )
  79. {
  80. System.out.println( "BASIL - Constructing Space. " );
  81. }
  82. }
  83.  
  84.  
  85.  
Success #stdin #stdout 0.06s 32808KB
stdin
Standard input is empty
stdout
BASIL - Constructing Space. 
BASIL - Done.