Java – mitosis of human cells
I am writing the genetic process in Java for my project. I want to simulate the mitosis of human cells Human cells contain 23 pairs of chromosomes Mitosis is basically cell division or reproduction, in which cells produce two genetically identical daughter cells You can find a related picture here (scroll down):
Mitosis
I think this mitosis is like a Java method in the class "cell" Therefore, I used its own method to make a class of chromosomes to represent a single chromosome, and made a "cell" class containing 23 pairs of chromosomes I plan to put the method mitosis in the cell class, but the problem is that this method should return two identical cells. I think it is impossible to create a method that returns two cells in this class I thought about making a method that returns an array of 2 cells, but it didn't work Any suggestions on how to create this method? Or maybe it's another method than the one I'm using? thank you.
Solution
I suggest that cell implement clonable and use the copy constructor idiom on the clone () method
In the domitosis () method in cell, you basically do the following:
public Cell[] doMitosis() { Cell[] cells = new Cell[]{this.clone(),this.clone()}; return cells; }
PS. the code is a rough sketch, not an actual implementation In addition, this code considers that the parent cell must be killed (and garbage collected) so that 2 identical cells can have permissions