JeTmAn81
Member
Everything sees to be a challenge for me. I'm actually completely stuck now. I'm still getting a 92% in the class, but I feel like I don't understand what's being asked alot of the time or why I'm doing the things I'm doing. The instructions for the mutate are
mutate This method will take no parameters. It will select at random (use the Math.random method) a position for a character in its dNACode and replace it with the character X. The method will return the current object (return this).
I feel like I'm close with this.
Code:int r1 = (int) (Math.random() * dNACode.length()); dNACode.replace(dNACode.charAt(r1), 'X'); this.dNACode = dNACode; return this.dNACode;
but probably not. I know I need to make a new string.
The next step after reverse is to create a new ComputerMicrobe.
reproduce This method takes another ComputerMicrobe as a parameter and creates a new ComputerMicrobe. This new ComputerMicrobe will have a name that is the concatenation of the name of this ComputerMicrobe with the name of the other ComputerMicrobe. The dNACode of the new ComputerMicrobe will take half of the dNACode of this ComputerMicrobe concatenated with half of the dNACode of the other ComputerMicrobe. The method will return the newly created ComputerMicrobe.
The driver won't compile if the class is wrong, so I've been using that to help steer me in the right direction. I can't even find any examples of the "reproduce" method. I guess that's what programming is about. I'm not worried about passing the class. I'm worried about moving from here to Programming Fundamentals and being completely lost.
Your mutate seems fine to me except you're told to return the whole object rather than the DNA code member.
To do reproduce, break down the steps needed for the method as far as you need to understand what's going on. If it seems too complex, test each statement to make sure it's doing what you want it to.