Program: 84679
Project: 84679
Buggy source:
public boolean ButtonPress(int ButtonID){
switch (ButtonID) {
case 1:
    GestureDefence.this.sm.NewWaveScreen();
  GestureDefence.this.sm.NewWaveScene.registerUpdateHandler(new TimerHandler(3.0f,true,new ITimerCallback(){
    @Override public void onTimePassed(    final TimerHandler pTimerHandler){
      GestureDefence.this.sm.NewWaveScene.unregisterUpdateHandler(pTimerHandler);
      GestureDefence.this.sm.GameScreen();
      GestureDefence.this.theWave.startNewWave();
    }
  }
));
return true;
case 3:
GestureDefence.this.theWave.NextWave();
GestureDefence.this.theWave.mWaveNumberMenuItem.setText("String_Node_Str" + theWave.getWaveNumber());
GestureDefence.this.sm.NewWaveScreen();
GestureDefence.this.sm.NewWaveScene.registerUpdateHandler(new TimerHandler(4.0f,true,new ITimerCallback(){
@Override public void onTimePassed(final TimerHandler pTimerHandler){
GestureDefence.this.sm.NewWaveScene.unregisterUpdateHandler(pTimerHandler);
GestureDefence.this.sm.GameScreen();
GestureDefence.this.theWave.startNewWave();
}
}
));
return true;
case 5:
if ((sMoney - 100 >= 0) && (GestureDefence.this.sCastle.getCurrentHealth() < GestureDefence.this.sCastle.getMaxHealth())) {
sMoney-=100;
sCastle.increaseHealth(100);
GestureDefence.this.theWave.mCashAmountItem.setText("String_Node_Str" + sMoney);
GestureDefence.this.theWave.mBuyMenuItem.setText("String_Node_Str" + GestureDefence.this.sCastle.getCurrentHealth() + "String_Node_Str"+ GestureDefence.this.sCastle.getMaxHealth());
GestureDefence.this.updateCashValue();
GestureDefence.this.updateCastleHealth();
}
return true;
case 7:
if (sMoney - 1000 >= 0) {
sMoney-=1000;
sCastle.increaseMaxHealth(250);
GestureDefence.this.theWave.mCashAmountItem.setText("String_Node_Str" + sMoney);
GestureDefence.this.theWave.mBuyMenuItem.setText("String_Node_Str" + GestureDefence.this.sCastle.getCurrentHealth() + "String_Node_Str"+ GestureDefence.this.sCastle.getMaxHealth());
GestureDefence.this.updateCashValue();
GestureDefence.this.updateCastleHealth();
}
return true;
case 9:
GestureDefence.this.theWave.setWaveNumber(1);
GestureDefence.this.sKillCount=0;
GestureDefence.this.sPreviousKillCount=0;
GestureDefence.this.sPreviousWaveNum=0;
GestureDefence.this.sMoney=0;
GestureDefence.this.mMoneyEarned=0;
GestureDefence.this.sEnemyCount=0;
GestureDefence.this.updateCashValue();
GestureDefence.this.sCastle.setCurrentHealth(3000);
GestureDefence.this.sCastle.setMaxHealth(3000);
GestureDefence.this.updateCastleHealth();
GestureDefence.this.mana=0;
GestureDefence.this.updateManaValue();
GestureDefence.this.sm.GameScreen.getChild(1).detachChildren();
GestureDefence.this.sm.GameScreen.getChild(3).detachChildren();
GestureDefence.this.getEngine().setScene(GestureDefence.this.sm.MainMenu);
return true;
case 99:
this.finish();
return true;
default :
return false;
}
}

Fixed version (ground truth):
public boolean ButtonPress(int ButtonID){
switch (ButtonID) {
case 1:
    GestureDefence.this.sm.NewWaveScreen();
  GestureDefence.this.sm.NewWaveScene.registerUpdateHandler(new TimerHandler(3.0f,true,new ITimerCallback(){
    @Override public void onTimePassed(    final TimerHandler pTimerHandler){
      GestureDefence.this.sm.NewWaveScene.unregisterUpdateHandler(pTimerHandler);
      GestureDefence.this.sm.GameScreen();
      GestureDefence.this.theWave.startNewWave();
    }
  }
));
return true;
case 3:
GestureDefence.this.theWave.NextWave();
GestureDefence.this.theWave.mWaveNumberMenuItem.setText("String_Node_Str" + theWave.getWaveNumber());
GestureDefence.this.sm.NewWaveScreen();
GestureDefence.this.sm.NewWaveScene.registerUpdateHandler(new TimerHandler(4.0f,true,new ITimerCallback(){
@Override public void onTimePassed(final TimerHandler pTimerHandler){
GestureDefence.this.sm.NewWaveScene.unregisterUpdateHandler(pTimerHandler);
GestureDefence.this.sm.GameScreen();
GestureDefence.this.theWave.startNewWave();
}
}
));
return true;
case 5:
if ((sMoney - 100 >= 0) && (GestureDefence.this.sCastle.getCurrentHealth() < GestureDefence.this.sCastle.getMaxHealth())) {
sMoney-=100;
sCastle.increaseHealth(100);
GestureDefence.this.theWave.mCashAmountItem.setText("String_Node_Str" + sMoney);
GestureDefence.this.theWave.mBuyMenuItem.setText("String_Node_Str" + GestureDefence.this.sCastle.getCurrentHealth() + "String_Node_Str"+ GestureDefence.this.sCastle.getMaxHealth());
GestureDefence.this.updateCashValue();
GestureDefence.this.updateCastleHealth();
}
return true;
case 7:
if (sMoney - 1000 >= 0) {
sMoney-=1000;
sCastle.increaseMaxHealth(250);
GestureDefence.this.theWave.mCashAmountItem.setText("String_Node_Str" + sMoney);
GestureDefence.this.theWave.mBuyMenuItem.setText("String_Node_Str" + GestureDefence.this.sCastle.getCurrentHealth() + "String_Node_Str"+ GestureDefence.this.sCastle.getMaxHealth());
GestureDefence.this.updateCashValue();
GestureDefence.this.updateCastleHealth();
}
return true;
case 9:
GestureDefence.this.theWave.setWaveNumber(1);
GestureDefence.this.sKillCount=0;
GestureDefence.this.sPreviousKillCount=0;
GestureDefence.this.sPreviousWaveNum=0;
GestureDefence.this.sMoney=0;
GestureDefence.this.mMoneyEarned=0;
GestureDefence.this.sEnemyCount=0;
GestureDefence.this.updateCashValue();
GestureDefence.this.sCastle.setCurrentHealth(3000);
GestureDefence.this.sCastle.setMaxHealth(3000);
GestureDefence.this.updateCastleHealth();
GestureDefence.this.mana=0;
GestureDefence.this.updateManaValue();
GestureDefence.this.sm.GameScreen.getChild(1).detachChildren();
GestureDefence.this.mOnScreenEnemies=0;
GestureDefence.this.sm.GameScreen.getChild(3).detachChildren();
GestureDefence.this.sm.loadMainMenu();
return true;
case 99:
this.finish();
return true;
default :
return false;
}
}