title: Writing a method that calls a member variable
body: <p>I want to find genes in a DNA string. Genes have START and STOP codons. </p>
  
  <p>The start codon is ATG. The stop codons are: TGA, TAA, TAG.</p>
  
  <p>This is an example of a DNA string: 
  AA<strong>ATG</strong>CCC<strong>TAA</strong>T<strong>TAG</strong>AA<strong>TAG</strong>TTCAA</p>
  
  <p>In order to find a gene, we must find the start codon (ATG) and the closest stop codon (TAG, TGA or TAA), that is a multiple of 3 characters away from the start codon, so in this case the gene would be </p>
  
  <p><strong>ATG</strong>CCC<strong>TAA</strong> </p>
  
  <p>and not </p>
  
  <p><strong>ATG</strong>CCCTAAT<strong>TAG</strong>, </p>
  
  <p>or</p>
  
  <p><strong>ATG</strong>CCCTAATTAGAA<strong>TGA</strong>, </p>
  
  <p>because TAG is 7 chars away from ATG and TGA, even though it's 12 chars away, it's not the closest STOP codon.</p>
  
  <p>I am to write a method called printAll, with one parameter, String dna, that calls the findStopIndex member variable, which will be used to print all the genes found in a DNA String, such as this one:CATGTAATAGATGAATGACTGATAGATATGCTTGTATGCTATGAAAATGTGAAATGACCCA.</p>
  
  <p>Here's the code I wrote so far:</p>
  
  <pre><code>public class ProteinFinder {
      public void printAllStarts(String dna)  {
          int start = 0;
          while (true) {
              int loc = dna.indexOf("atg", start);
              if (loc == -1) {
                  break;
              }
              System.out.println("Starts at " + loc);
              start = loc + 3;
          }
      }
  
      public int findStopIndex(String dna, int index) {
          int stop1 = dna.indexOf("tga", index);
          if (stop1 == -1 || (stop1 - index) % 3!=0) { 
              stop1 = dna.length();
          }
          System.out.println(stop1);
  
          int stop2 = dna.indexOf("taa", index);
          if (stop2 == -1 || (stop2 - index) %3 !=0) {
              stop2 = dna.length();
          }
          System.out.println(stop2);
          int stop3 = dna.indexOf("tag", index);
          if (stop3 == -1 || (stop3 - index) %3 !=0) {
              stop3 = dna.length();
          }
          System.out.println(stop3);
          return Math.min(stop1, Math.min(stop2, stop3));
      }    
      public void printAll(String dna) {
  
      }    
  }
  </code></pre>
  
  <p>Could you help me write this method? Thank you.</p>