Question: I need help debugging this code public void actionPerformed ( ActionEvent e ) { if ( e . getSource ( ) = = buttonStart )
I need help debugging this code public void actionPerformed ActionEvent e
ifegetSource buttonStart
level ;
score ;
robotCount ;
moveFactor ;
robotsKilled ;
alive true;
nextLevel false;
scoreString "Level level "score score;
currentScoreField.setTextscoreString;
resultsString "Starting a game";
resultsArea.setTextresultsString;
initializeBoard board;
placeHuman board;
robotsX new introbotCount;
robotsY new introbotCount;
robotsAlive new booleanrobotCount;
set robots alive
for int i ; i robotCount; i
robotsAlivei true;
place robots
placeRobotsrobotCount robotsX,robotsY, board;
dislplay board
displayBoardboard;
if its not the start button
else if egetSource buttonStart && robotsAlive true && nextLevel false
if egetSource buttonUp
moveHumanboard;
moveRobotshumanX humanY, robotCount, robotsX, robotsY, robotsAlive, board, moveFactor;
if egetSource buttonRight
moveHumanboard;
moveRobotshumanX humanY, robotCount, robotsX, robotsY, robotsAlive, board, moveFactor;
if egetSource buttonDown
moveHumanboard;
moveRobotshumanX humanY, robotCount, robotsX, robotsY, robotsAlive, board, moveFactor;
if egetSource buttonLeft
moveHumanboard;
moveRobotshumanX humanY, robotCount, robotsX, robotsY, robotsAlive, board, moveFactor;
nextLevel winLevel;
if nextLevel true
update the results string
resultsString "you win level level;
resultsArea.setTextresultsString;
level;
update the score string
robotsKilled deadRobotsrobotCount robotsAlive;
score robotsKilled ;
update the score field
scoreString "Level level Score ;
currentScoreField.setTextscoreString;
reset the robotsKilled value
robotsKilled ;
robotCount;
moveFactor ;
initializeBoardboard;
placeHumanboard;
alive true;
nextLevel false;
creat new robot team
robotsX new int robotCount;
robotsY new int robotCount;
robotsAlive new boolean robotCount;
for int i ; i robotCount; i
robotsAlivei true;
placeRobotsrobotCount robotsX, robotsY, board;
alive analyzehumanX humanY, robotsX, robotsY, board;
if alivegame over
robotsKilled deadRobots robotCount robotsAlive;
score robotsKilled;
scoreString "Level" level "Score score;
currentScoreField.setTextscoreString;
if humanX humanX humanY humanY && humanY && humanX
resultsString "You were zapped by the electric fence!"
If you want to play again click start.";
else
resultsArea.setTextresultsString;
displayBoardboard;
end of actionPerformed
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
