Question: Reorganize the code of the sorting animation in Section 22.6 so that it can be used for generic animations. Provide a class Animated with abstract

Reorganize the code of the sorting animation in Section 22.6 so that it can be used for generic animations.

Provide a class Animated with abstract methods

public void run() public void draw (Graphics g, int width, int height)

and concrete methods public void lock() public void unlock (int steps) public

public void run() public void draw (Graphics g, int width, int height) and concrete methods public void lock() public void unlock (int steps) public void setComponent (JComponent component) so that the Selection Sorter can be implemented as public class Selection Sorter extends Animated { private int[] a; private int marked Position = -1; private int alreadySorted = -1; public Selection Sorter(int[] anArray) { a = anArray; } public void run() { } for (int i = 0; i < a.length 1; i++) { } int minPos= minimumPosition (i); lock(); ArrayUtil.swap(a, minPos, i); alreadySorted = i; unlock(2);

Step by Step Solution

3.35 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

From the context of the question youve provided its clear you are dealing with a Java program that contains an animation of a sorting algorithmin this case selection sort The goal is to refactor the c... View full answer

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 Java Programming Questions!