### Question:
Beat implements Comparable<Beat> { @Override public int compareTo(Beat o) { if (beatIndex > o.beatIndex) { return 1; } else if (beatIndex < o.beatIndex) { return -1; } if (string > o.string) { return 1; } else if (string < o.string) { return -1; } return 0; } Beat(int beatIndex, int string, int fret, int duration); int getBeatIndex(); int getFret(); int getString(); int getDuration(); @Override int compareTo(Beat o);  }### Answer:
@Test public void testCompareTo() throws Exception { Beat beat1 = new Beat(0, 2, 0, 5); Beat beat2 = new Beat(0, 3, 0, 5); Beat beat3 = new Beat(1, 3, 0, 5); assertThat(beat1.compareTo(beat2)).isLessThan(0); assertThat(beat1.compareTo(beat3)).isLessThan(0); assertThat(beat1.compareTo(beat3)).isLessThan(0); assertThat(beat1.compareTo(beat1)).isEqualTo(0); }