kid
2011-07-07 22:05:07 UTC
for(int element = 0; element < 64; element++){
int current_data = data_to_process[element];
System.out.println("## value of current_data before switch: " + current_data);
switch(current_data){
case 1:
grid_cells[element] = new Regular_Block();
System.out.print("@@ in case 1");
System.out.println(" @@ value of current_data: " + current_data);
case 2:
grid_cells[element] = new Wood_Block();
System.out.print("@@ in case 2");
System.out.println(" @@ value of current_data: " + current_data);
case 3:
grid_cells[element] = new Metal_Block();
System.out.print("@@ in case 3");
System.out.println(" @@ value of current_data: " + current_data);
case 5:
grid_cells[element] = new Regular_Block();
System.out.print("@@ in case 5");
System.out.println(" @@ value of current_data: " + current_data);
default:
System.out.print("@@ in default");
System.out.println("@@ value of current_data: " + current_data);
***output***
## value of current_data before switch: 3
@@ in case 3 @@ value of current_data: 3
@@ in case 5 @@ value of current_data: 3
@@ in default@@ value of current_data: 3
Now, that input above? That is all the output before the line above switch statement gets new input, in which the code continues to do this wonky thing. The input shows that the switch statement is sending the SAME number into 3 cases: one that matches the number, one that DOESNT match the number, and the default. WHY IS THE SWITCH STATEMENT SENDING ONE NUMBER INTO 3 CASES??