### Question:
Chromosome implements Comparable<Chromosome> { @Override public int compareTo(Chromosome c) { if (fitness < c.fitness) { return -1; } else if (fitness > c.fitness) { return 1; } return 0; } Chromosome(String gene); String getGene(); int getFitness(); Chromosome mutate(); Chromosome[] mate(Chromosome mate); @Override int compareTo(Chromosome c); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testCompareTo() { Chromosome c1 = new Chromosome("Hello, world!"); assertEquals(0, c1.getFitness()); Chromosome c2 = new Chromosome("H5p&J;!l<X\\7l"); assertEquals(399, c2.getFitness()); Chromosome c3 = new Chromosome("Vc;fx#QRP8V\\$"); assertEquals(297, c3.getFitness()); Chromosome c4 = new Chromosome("t\\O`E_Jx$n=NF"); assertEquals(415, c4.getFitness()); assertEquals(0, c1.compareTo(c1)); assertTrue(c1.compareTo(c2) < 0); assertTrue(c1.compareTo(c3) < 0); assertTrue(c1.compareTo(c4) < 0); assertEquals(0, c2.compareTo(c2)); assertTrue(c2.compareTo(c1) > 0); assertTrue(c2.compareTo(c3) > 0); assertTrue(c2.compareTo(c4) < 0); assertEquals(0, c3.compareTo(c3)); assertTrue(c3.compareTo(c1) > 0); assertTrue(c3.compareTo(c2) < 0); assertTrue(c3.compareTo(c4) < 0); assertEquals(0, c4.compareTo(c4)); assertTrue(c4.compareTo(c1) > 0); assertTrue(c4.compareTo(c2) > 0); assertTrue(c4.compareTo(c3) > 0); }