Posted By

ptx-chris on 12/03/10


Tagged


Versions (?)

Array Exception


 / Published in: Java
 

  1. public class Array3D {
  2.  
  3. public static String roomStrings [][][] = new String[6][3][];
  4.  
  5. public static void main(String[] args) {
  6. System.out.println("test");
  7. initRoomStrings();
  8. System.out.println("test");
  9. System.out.println(roomStrings[0][1][1]);
  10.  
  11. System.out.println(roomStrings[0][2][1]);
  12.  
  13. for(int l1 = 0; l1 < roomStrings.length ; l1++){
  14.  
  15. for(int l2=0; l2 < roomStrings[l1].length ; l2++){
  16.  
  17. for(int l3=0;l3 < roomStrings[l1][l2].length; l3++){
  18. System.out.println(roomStrings[l1][l2][l3]);
  19. }
  20. }
  21. }
  22.  
  23. }
  24. public static void initRoomStrings(){
  25.  
  26. roomStrings[0][0] = new String[1]; // Name
  27. roomStrings[0][1] = new String[3]; // Choices
  28. roomStrings[0][2] = new String[3]; // Consequences
  29.  
  30. roomStrings[0][0][1] = "Raum 1";
  31.  
  32. roomStrings[0][1][0] = "Choice 1";
  33. roomStrings[0][1][1] = "Choice 2";
  34. roomStrings[0][1][1] = "Choice 3";
  35.  
  36. roomStrings[0][2][0] = "Consequence 1";
  37. roomStrings[0][2][1] = "Consequence 2";
  38. roomStrings[0][2][1] = "Consequence 3";
  39.  
  40. //Strings for room 1
  41. roomStrings[1][0] = new String[1]; // Name
  42. roomStrings[1][1] = new String[3]; // Choices
  43. roomStrings[1][2] = new String[3]; // Consequences
  44.  
  45. roomStrings[1][0][1] = "Raum 1";
  46.  
  47. roomStrings[1][1][0] = "Choice 1";
  48. roomStrings[1][1][1] = "Choice 2";
  49. roomStrings[1][1][1] = "Choice 3";
  50.  
  51. roomStrings[1][2][0] = "Consequence 1";
  52. roomStrings[1][2][1] = "Consequence 2";
  53. roomStrings[1][2][1] = "Consequence 3";
  54.  
  55. //Strings for room 2
  56. roomStrings[2][0] = new String[1]; // Name
  57. roomStrings[2][1] = new String[3]; // Choices
  58. roomStrings[2][2] = new String[3]; // Consequences
  59.  
  60. roomStrings[2][0][1] = "Raum 2";
  61.  
  62. roomStrings[2][1][0] = "Choice 1";
  63. roomStrings[2][1][1] = "Choice 2";
  64. roomStrings[2][1][1] = "Choice 3";
  65.  
  66. roomStrings[2][2][0] = "Consequence 1";
  67. roomStrings[2][2][1] = "Consequence 2";
  68. roomStrings[2][2][1] = "Consequence 3";
  69.  
  70. //Strings for room 3
  71. roomStrings[3][0] = new String[1]; // Name
  72. roomStrings[3][1] = new String[3]; // Choices
  73. roomStrings[3][2] = new String[3]; // Consequences
  74.  
  75. roomStrings[3][0][1] = "Raum 3";
  76.  
  77. roomStrings[3][1][0] = "Choice 1";
  78. roomStrings[3][1][1] = "Choice 2";
  79. roomStrings[3][1][1] = "Choice 3";
  80.  
  81. roomStrings[3][2][0] = "Consequence 1";
  82. roomStrings[3][2][1] = "Consequence 2";
  83. roomStrings[3][2][1] = "Consequence 3";
  84.  
  85. //Strings for room 4
  86. roomStrings[4][0] = new String[1]; // Name
  87. roomStrings[4][1] = new String[3]; // Choices
  88. roomStrings[4][2] = new String[3]; // Consequences
  89.  
  90. roomStrings[4][0][1] = "Raum 4";
  91.  
  92. roomStrings[4][1][0] = "Choice 1";
  93. roomStrings[4][1][1] = "Choice 2";
  94. roomStrings[4][1][1] = "Choice 3";
  95.  
  96. roomStrings[4][2][0] = "Consequence 1";
  97. roomStrings[4][2][1] = "Consequence 2";
  98. roomStrings[4][2][1] = "Consequence 3";
  99.  
  100. //Strings for room 5
  101. roomStrings[5][0] = new String[1]; // Name
  102. roomStrings[5][1] = new String[3]; // Choices
  103. roomStrings[5][2] = new String[3]; // Consequences
  104.  
  105. roomStrings[5][0][1] = "Raum 5";
  106.  
  107. roomStrings[5][1][0] = "Choice 1";
  108. roomStrings[5][1][1] = "Choice 2";
  109. roomStrings[5][1][1] = "Choice 3";
  110.  
  111. roomStrings[5][2][0] = "Consequence 1";
  112. roomStrings[5][2][1] = "Consequence 2";
  113. roomStrings[5][2][1] = "Consequence 3";
  114. }
  115. }

Report this snippet  

You need to login to post a comment.