0
我试图在其他设备上更改我的代码,并通过Dropbox从其他设备获取代码,但是当我在代码中进行更改时,程序的行为与以前相同。我不知道为什么?!为什么Eclipse编辑器中的更改不会影响我的代码?
//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);
。这也不会影响我的代码。
清理并重新构建它..从build/bin删除类然后尝试执行 – Madhan
谢谢,它的工作原理! –