Buggy code:
public class Battle { DungeonCharacter [ ] heroes ; DungeonCharacter [ ] enemies ; Inventory inventory ; public Battle ( DungeonCharacter [ ] heroes , Inventory inventory ) { } public void printDescription ( ) { } public void startBattle ( ) { DungeonCharacter [ ] order = concat ( heroes , enemies ) ; boolean heroStatus = checkStatus ( heroes ) ; boolean enemyStatus = checkStatus ( enemies ) ; while ( heroStatus && enemyStatus ) { for ( int x = 0 ; x < ( order . length ) ; x ++ ) { CharacterPrint . printOrder ( order , x ) ; if ( heroStatus && enemyStatus ) { if ( order [ x ] . isAlive ( ) ) { int damage = 0 ; int item = 0 ; if ( order [ x ] . isHero ( ) ) { System . out . println ( "-----------------------------------------------------------------" ) ; CharacterPrint . getInstance ( ) . StatusPrint ( heroes , "Heroes" ) ; System . out . println ( "-----------------------------------------------------------------" ) ; CharacterPrint . getInstance ( ) . StatusPrint ( enemies , "Enemies" ) ; System . out . println ( "-----------------------------------------------------------------" ) ; } int action = selectAction ( order [ x ] ) ; if ( action == 3 ) { inventory . printConsumables ( ) ; item = inventory . selectItem ( new Scanner ( System . in ) ) ; } int target = selectTarget ( order , heroes , x ) ; if ( action == 1 ) { damage = order [ x ] . attack ( order [ target ] ) ; } else if ( action == 2 ) { damage = order [ x ] . special ( order [ target ] ) ; } else if ( action == 3 ) { System . out . print ( ( ( order [ target ] . getName ( ) ) + "<seq2seq4repair_space>" ) ) ; inventory . consume ( ( item - 1 ) , order [ target ] ) ; } if ( action != 3 ) System . out . println ( ( ( ( ( ( ( order [ x ] . getName ( ) ) + "<seq2seq4repair_space>hit<seq2seq4repair_space>" ) + ( order [ target ] . getName ( ) ) ) + "<seq2seq4repair_space>for<seq2seq4repair_space>" ) + damage ) + "<seq2seq4repair_space>damage!" ) ) ; heroStatus = checkStatus ( heroes ) ; enemyStatus = checkStatus ( enemies ) ; } } } reduceAllConsumables ( order ) ; } if ( heroStatus ) { System . out . println ( "You<seq2seq4repair_space>won<seq2seq4repair_space>the<seq2seq4repair_space>battle!" ) ; int expGained = 0 ; for ( int i = 0 ; i < ( enemies . length ) ; i ++ ) { <START_BUG> expGained = enemies [ i ] . getExp ( ) ; <END_BUG> } System . out . println ( ( ( "You<seq2seq4repair_space>gained<seq2seq4repair_space>" + expGained ) + "<seq2seq4repair_space>experience" ) ) ; for ( int i = 0 ; i < ( heroes . length ) ; i ++ ) { if ( heroes [ i ] . isAlive ( ) ) heroes [ i ] . gainExperience ( expGained ) ; } } else { System . out . println ( "--GAME<seq2seq4repair_space>OVER--" ) ; } } private int selectTarget ( DungeonCharacter [ ] order , DungeonCharacter [ ] heroes , int x ) { } private int selectAction ( DungeonCharacter attacker ) { } private boolean checkStatus ( DungeonCharacter [ ] dudes ) { } private DungeonCharacter [ ] concat ( DungeonCharacter [ ] heroes , DungeonCharacter [ ] enemies ) { } private DungeonCharacter [ ] MirrorSort ( int [ ] initative , DungeonCharacter [ ] characters ) { } public void reduceAllConsumables ( DungeonCharacter [ ] order ) { } No newline ; at end ; of file ; }

Fix:
expGained += enemies [ i ] . getExp ( ) ;