Commit 2213c767 authored by Trisha Gee's avatar Trisha Gee
Browse files

[App A] Using a sorted Map to store the values so that they're always in the...

[App A] Using a sorted Map to store the values so that they're always in the same order when we iterate over them
parent 121c950b
Loading
Loading
Loading
Loading
+7 −2
Changes for src/main/java/appA/BeatBoxFinal.java: 7 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ import java.util.*;
public class BeatBoxFinal {
  public static final int NUMBER_OF_BEATS = 16;
  private final List<BeatInstrument> instruments;
  private final Map<BeatInstrument, List<JCheckBox>> instrumentCheckboxes = new HashMap<>();
  private final Map<BeatInstrument, List<JCheckBox>> instrumentCheckboxes = new TreeMap<>();

  private JList<String> messages;
  private JTextField userMessage;
@@ -288,7 +288,7 @@ public class BeatBoxFinal {
    return event;
  }

  private static class BeatInstrument {
  private static class BeatInstrument implements Comparable<BeatInstrument>{
    private final String instrumentName;
    private final int midiValue;

@@ -304,6 +304,11 @@ public class BeatBoxFinal {
    public int getMidiValue() {
      return midiValue;
    }

    @Override
    public int compareTo(BeatInstrument other) {
      return instrumentName.compareTo(other.instrumentName);
    }
  }
}