Hi, welcome back to gene-finding, yet another time. In this version of the program that we're writing to find genes, we're going to make one small change to what we return when we look for a stop codon. And that change is going to mean that we have to use some complex boolean expressions using ands and ors to make our code work properly. So as we've already seen, the one small change we're going to make is that instead of returning dnaStr.length() to indicate that no stop codon was found, we're going to return -1. That's a good value to return to indicate that nothing was found, because now our code mirrors what for example the indexOf method in the String class uses. It uses -1 to indicate that no string was found when searching. Now our findStopCodon method also returns -1. Now that change means that our test function won't work correctly. Remember, we had a test function down here. These functions will now fail because they didn't find that. So to see that, very quickly, I'm going to run this new class, create an object on the object workbench, and test the findStopCodons. And you can see I got an error 26 twice. And that's because in my program, I had if it's not equal to 26. So if I change that to -1. Compile. And now test my program again. Finding stopCodons. I can see that my tests finished. So my test program needed to change to recognize this return value of -1 rather than the length of the string. Now I'm confident that my stopCodon method, with this one small change, works correctly and that it returns -1 to indicate that no stopCodon was found. That means my findGene method is also going to need to change. Rather than using Math.min, I'm going to need these boolean expressions that you've just learned about. And I've put here in my comments what those boolean expressions are supposed to do. So I'm going to simply translate this stuff, the comments from my seven step process, into code. And what that code says here is, if (taaIndex == -1 || and we use that double vertical bar for or, or (tgaIndex != -1 && tgaIndex < taaIndex). Now, that's a lot. So let's look and make sure we got that right. It says, if taaIndex equals -1 or tgaIndex is not equal to -1 and tgaIndex is less than taaIndex. In that case, it says, set minIndex to tgaIndex. So I'm going to say minIndex = tgaIndex; just as it says there. That means I'm going to not use these versions of minIndex, which werer from before. But if I compile this code, I'm going to get an error message, something about temp. So if I comment that out. Let me comment all of these out. Now I get that variable minIndex isn't known. So I'm going to define minIndex. And I need to give it a value. I need to give it some value. I'll just give it 0. I'm going to put in my else statement here. What it says to else set minIndex to taaIndex, else minIndex gets taaIndex. So what I've got now in my code is a translation of if taaIndex is equal to -1 or tgaIndex is not equal to -1 and this expression, then set minIndex to tgaIndex, also set minIndex to this value. Then, I still have yet another boolean expression to write. I need to write, if minIndex is equal to -1 or tgaIndex is not equal to -1 and tagIndex is less than minIndex. In that case, my comments say, set minIndex to tagIndex. So I'm writing that. I'm simply translating this into my code here. Finally, it says, if minIndex is equal to -1 rather than dna.length(), return the empty string. Otherwise, return this. My program compiles, well, almost compiles, I forgot second a parenthesis up here, but that's an easy thing to fix. Well, maybe not fixing it that way by erasing it all. Maybe I should type in a parenthesis instead. Now when I compile my program, it works. How do I test this? Before, in the previous version, I didn't have a test program, a test method. Now I do. I have my test method, findGene. So I'm going to try that out. See if it works. Right-click to create an object. Right-click to testing findGene(). And it just simply printed, tests finished. Which is what I wanted, since in findGene() I looked for a gene. I found this start codon, and I found this stop codon, TAA. Now, I could change this TAA to a different stop codon, and I would keep testing those to make sure that my method works correctly. I'll leave that to you, because as we've already seen, testing is as important as writing your code. Because you need to be sure your methods work correctly. Have fun testing. Have real fun programming.