Actually, what I even use to clone my cells. But this is not cell cloning, which is my problem, this is what the mitosis method should bring back. While mitosis (biologically), two identical cells arise.
You hung up trying to get Java to act like an object in the real world.
What you should focus on is the correct number of correct cells after mitosis, and not that the method signatures directly reflect real-world events.
Mitosis is a place where one cell is divided into two parts. IMO, any of the following valid "models" in Java:
a method in this cell that returns another:
public Cell mitosis() { return this.clone();
a method in this cell that returns two cells:
public Cell[] mitosis() { return new Cell[]{this, this.clone()}; // ... note - must return this as one // of the objects }
static method that returns two cells:
public static Cell[] mitosis(Cell one) { return new Cell[]{one, one.clone()}; }
Even the following may be correct ... if the caller takes care to remove all links to the original cell.
public static Cell[] mitosis(Cell original) { return new Cell[]{original.clone(), original.clone()}; }
But I want to say that it doesnβt really matter what signatures are. The important thing is that after the method (and the caller) has done things there, the new model has the right Cell objects in the right relationship.
Stephen c
source share