Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started