Assignment J3

The methods we chose to implement should provide insight on how you can implement the other methods.

Several of the methods that you must develop currently have a dummy placeholder statement in them. The placeholders allow the class to successfully compile. A placeholder is to be removed after you have added your code. For example, here is the listing for one substrand() methods as given in Strand.java.

public Strand substrand(int i) {
    // TO BE COMPLETED *********

    return null; // delete this line after you have written the method
}

Because substrand() is suppose to return a Strand, the method would not compile without some sort of return value. The dummy return provides that value.

For your information here are our implementations of toString(), splice(), and clone()

// toString(): return String representation of the object
    public String toString() {
    String result = "< " + this.nucleotideSequence + " >";
    return result;
}

// splice(): append the Strand with another strand
public void splice(Strand otherStrand) {
    // determine the concatenation components
    String leading = this.nucleotideSequence;
    String trailing = otherStrand.nucleotideSequence;

    // update strand to be a concatenation
    this.nucleotideSequence = leading + trailing;
}

// clone(): duplicate the existing strand
public Object clone() {
    // duplicate the sequence
    String duplicateSequence = new String(nucleotideSequence);
    // return a new Strand using the duplication
    Strand result = new Strand(duplicateSequence);
    return result;
}