Can someone explain me why my loop is going from 0 to 7? I need to get only in the first 3 cases, but the program is going through all.. The code is in the show() method.
for(brojac=0; brojac<3; brojac++){
switch(brojac){
case 1:
figura1.setPosition(pomx[random], pomy[random]);
stage.addActor(figura1);
System.out.println("1");
case 2:
figura2.setPosition(pomx[random], pomy[random]);
stage.addActor(figura2);
System.out.println("2");
case 3:
figura3.setPosition(pomx[random], pomy[random]);
stage.addActor(figura3);
System.out.println("3");
case 4:
figura4.setPosition(pomx[random], pomy[random]);
stage.addActor(figura4);
System.out.println("4");
case 5:
figura5.setPosition(pomx[random], pomy[random]);
stage.addActor(figura5);
System.out.println("5");
case 6:
figura6.setPosition(pomx[random], pomy[random]);
stage.addActor(figura6);
System.out.println("6");
case 7:
figura7.setPosition(pomx[random], pomy[random]);
stage.addActor(figura7);
System.out.println("7");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…