我尝试在另一台设备上更改代码,并通过 Dropbox 将代码从一台设备传输到另一台设备,但是当我更改代码时,程序的行为与以前相同。不知道为什么?!
//when collecting an Powerup-Item start a random Powerup
public static void pupHit() {
ItemCreator.powerUp.setLocation(new Point(-50, -50));
//usually I would generate a random number between 1 and 6
//with the commented 2 lines below and save it in the variable pup
//Random rand = new Random();
int pup = 6; //rand.nextInt(6) + 1;
//even if I give pup a static value of 6, pup differs between 1 and 5/6
switch(pup){
case 1: ItemPowerups.speed(); Stats.points += 10; break;
case 2: ItemPowerups.slow(); Stats.points += 5; break;
case 3: ItemPowerups.lsd(); Stats.points += 15; break;
case 4: ItemPowerups.invert(); Stats.points += 25; break;
case 5: ItemPowerups.obstacle(); Stats.points += 10; break;
case 6: ItemPowerups.steelJawbone(); Stats.points += 10; break;
}
}
我尝试在声明和初始化pup
后添加System.out.printl(pup);
。这也不会影响我的代码。
最佳答案
尝试再次构建它:D。 (我知道最后一个人解决了这个问题,但我们需要这个问题才能得到答案)。
关于java - 为什么 Eclipse 编辑器中的更改不会影响我的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31091037/