Question: I have the following java program. I want the track to count the number of moves and update the count by each move. As it

I have the following java program. I want the track to count the number of moves and update the count by each move. As it is now, it doesn't update the answer, it just writes over the old count.

I have the following java program. I want the track to count

the number of moves and update the count by each move. As

it is now, it doesn't update the answer, it just writes over

the old count. public static void KeysO throws InterruptedException if (StdDraw. isKeyPressed(KeyEvent.

public static void KeysO throws InterruptedException if (StdDraw. isKeyPressed(KeyEvent. VK_1)) I oldPos pos.clone) pos[A] += distance[X)-1; pos[] += distance[]- 1; moves ++ drawL ines(pos,oldPos); drawDot(pos[X], pos[YM); Distance; Thread.sleep(500); j else if ( StdDraw. isKeyPressedCKeyEvent. VK_2)) oldPos = pos.clone(); pos[X) += distance[X); pos[distance[]- 1; moves ++ drawL ines(pos,oldPos); drawDot(pos[X, pos[YM); DistanceO; Thread. sleep(500); I else if ( StdDraw. isKeyPressed(KeyEvent.VK_3)) oldPos- pos. clone(); pos[X) +-distance[X) -1; posM += distance[Y] + 1; moves ++ drawLines(pos,oldPos); drawDot(pos[X1, pos[YM) DistanceO; Thread.sleep(500); t else if ( StdDraw. isKeyPressed(KeyEvent.VK_4)) oldPos = pos.clone(); pos[X) += distance[X) -1; posDYM +distanceLYA moves ++ drawLinesCpos,oldPos); drawDot(posDX], posLYM); Distance(O; Thread.sleep(500); public static void KeysO throws InterruptedException if (StdDraw. isKeyPressed(KeyEvent. VK_1)) I oldPos pos.clone) pos[A] += distance[X)-1; pos[] += distance[]- 1; moves ++ drawL ines(pos,oldPos); drawDot(pos[X], pos[YM); Distance; Thread.sleep(500); j else if ( StdDraw. isKeyPressedCKeyEvent. VK_2)) oldPos = pos.clone(); pos[X) += distance[X); pos[distance[]- 1; moves ++ drawL ines(pos,oldPos); drawDot(pos[X, pos[YM); DistanceO; Thread. sleep(500); I else if ( StdDraw. isKeyPressed(KeyEvent.VK_3)) oldPos- pos. clone(); pos[X) +-distance[X) -1; posM += distance[Y] + 1; moves ++ drawLines(pos,oldPos); drawDot(pos[X1, pos[YM) DistanceO; Thread.sleep(500); t else if ( StdDraw. isKeyPressed(KeyEvent.VK_4)) oldPos = pos.clone(); pos[X) += distance[X) -1; posDYM +distanceLYA moves ++ drawLinesCpos,oldPos); drawDot(posDX], posLYM); Distance(O; Thread.sleep(500)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!