Skip to content

Commit 6a5781b

Browse files
authored
Update SortArray.java
1 parent 5906ef2 commit 6a5781b

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/sortvisualiser/SortArray.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
/**
2424
* The array that can be sorted
25-
*
26-
* @author mhops
2725
*/
2826
public class SortArray extends JPanel {
2927
public static final int DEFAULT_WIN_WIDTH = 1280;
@@ -45,11 +43,8 @@ public class SortArray extends JPanel {
4543
private ISortAlgorithm algorithm;
4644
private long algorithmDelay = 0;
4745

48-
// private final MidiSoundPlayer player;
4946
private final JSpinner spinner;
50-
// private final boolean playSounds;
5147

52-
private int arrayChanges = 0; // Number of changes to the array the current algorithm has taken so far
5348

5449
public SortArray() {
5550
setBackground(Color.DARK_GRAY);
@@ -59,8 +54,6 @@ public SortArray() {
5954
array[i] = i;
6055
barColours[i] = 0;
6156
}
62-
// player = new MidiSoundPlayer(NUM_BARS);
63-
// this.playSounds = playSounds;
6457
spinner = new JSpinner(new SpinnerNumberModel(1, 1, 1000, 1));
6558
spinner.addChangeListener((event) -> {
6659
algorithmDelay = (Integer) spinner.getValue();
@@ -92,11 +85,6 @@ private void finaliseUpdate(int value, long millisecondDelay, boolean isStep) {
9285
} catch (InterruptedException ex) {
9386
Thread.currentThread().interrupt();
9487
}
95-
// if (playSounds) {
96-
// player.makeSound(value);
97-
// }
98-
if (isStep)
99-
arrayChanges++;
10088
}
10189

10290
public void swap(int firstIndex, int secondIndex, long millisecondDelay, boolean isStep) {
@@ -120,13 +108,11 @@ public void updateSingle(int index, int value, long millisecondDelay, boolean is
120108
}
121109

122110
public void shuffle() {
123-
arrayChanges = 0;
124111
Random rng = new Random();
125112
for (int i = 0; i < arraySize(); i++) {
126113
int swapWithIndex = rng.nextInt(arraySize() - 1);
127114
swap(i, swapWithIndex, 5, false);
128115
}
129-
arrayChanges = 0;
130116
}
131117

132118
public void highlightArray() {
@@ -167,7 +153,6 @@ public void paintComponent(Graphics g) {
167153
panelGraphics.drawString(" Current algorithm: " + algorithmName, 10, 30);
168154
panelGraphics.drawString(" Time Complexity & Space Complexity: " + tandComplexity, 10, 55);
169155
panelGraphics.drawString("Current step delay: " + algorithmDelay + "ms", 10, 80);
170-
// panelGraphics.drawString(" Array Changes: " + arrayChanges, 10, 105);
171156

172157
drawBars(panelGraphics);
173158
} finally {
@@ -261,4 +246,4 @@ public void setAlgorithm(ISortAlgorithm algorithm) {
261246
algorithmDelay = algorithm.getDelay();
262247
spinner.setValue((int) algorithm.getDelay());
263248
}
264-
}
249+
}

0 commit comments

Comments
 (0)