Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Baby Code With Test
package code.family.additions;
import java.util.Calendar;
import java.util.Date;
public class BabyCode extends Code {
public Date DueDate;
public BabyCode(Code mother, Code father) {
super();
Utility utils = new Utility();
_genes = utils.join(mother.GetReproductiveGenes(), father.GetReproductiveGenes());
CalculateDueDate(mother.GetOvulationDate());
}
protected void CalculateDueDate(Calendar date) {
date.add(Calendar.DAY_OF_WEEK,266);
DueDate = new Date(date.getTimeInMillis());
}
}
package code.family.additions;
import static org.junit.Assert.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.junit.Before;
import org.junit.Test;
public class BabyCodeTests {
private BabyCode newBaby;
private Code father;
private Code mother;
@Before
public void setup() {
father = new Code("Shannon Code");
mother = new Code("Dawn Code");
}
@Test
public void BabyIsNotNull() throws ParseException {
mother.SetOvulationDate(new SimpleDateFormat("MM/dd/yyyy").parse("11/14/2011"));
newBaby = new BabyCode(mother,father);
assertNotNull(newBaby.DueDate);
}
}
package code.family.additions;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
public class Code {
private String _name;
public Code() {}
public Code(String name) {_name = name;}
protected Date _ovulationDate;
protected String[] _genes;
public String[] GetReproductiveGenes() {
return new String[]{"A", "T", "G", "C"};
}
public void SetOvulationDate(Date date) throws ParseException {
_ovulationDate = date;
}
public Calendar GetOvulationDate() {
Calendar date = Calendar.getInstance();
date.set(Calendar.DAY_OF_MONTH, _ovulationDate.getDate());
date.set(Calendar.MONTH, _ovulationDate.getMonth());
date.set(Calendar.YEAR, _ovulationDate.getYear());
return date;
}
}
@ripper234

This comment has been minimized.

Copy link

ripper234 commented Aug 8, 2014

Congratulations, even if overdue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.