public class Genome { // OVERVIEW: A genome is an immutable type for representing sequence of base pairs. private /*@non_null@*/ String dna; public Genome (/*@non_null@*/ String s) { dna = s; } public String toString () { return dna; } int mutationDistance (/*@non_null@*/ Genome g) // effects Returns the number of point mutations required to turn // this into g. Each mutation changes the value of one // base. (We are not allowing insertions, deletions, etc. // for now.) { int size = dna.length (); int mutations = 0; if (dna.length () > g.dna.length ()) { size = g.dna.length (); mutations += (dna.length () - size); } else if (g.dna.length () > size) { mutations += (g.dna.length () - size); } for (int i = 0; i < size; i++) { if (dna.charAt (i) != g.dna.charAt (i)) { mutations++; } } return mutations; } }