Instead of using a thread and a pause method, use the Timer class introduced in Section 10.9
Question:
Instead of using a thread and a pause method, use the Timer class introduced in Section 10.9 to ani mate an algorithm. Whenever the timer sends out an action event, run the algorithm to the next step and display the state. That requires a more extensive recoding of the algorithm. You need to implement a runToNextStep method that is capable of running the algorithm one step at a time. Add sufficient instance variables to the algorithm to remember where the last step left off. For example, in the case of the selection sort algorithm, if you know the values of alreadySorted and markedPosition, you can determine the next step.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: