Please refer to my last couple of posts.
private void gestationPeriod() { gestationcycles++; if( gestationcycles == MONTH ) { gestationcycles = 0; gestation++; if( gestation == BIRTH_TIME ) { getWorld().addObject(new Ladybug(0),getX(),getY()); gestation=0; gestated=false; } } } private void becomingPregnant() { Ladybug bug = (Ladybug)getOneIntersectingObject(Ladybug.class); if(bug != null && !bug.isOld() && bug.isAdult() && !isOld() && isAdult() && isFemale() && bug.isMale() && !isPregnant() && Greenfoot.getRandomNumber(100)<20){ gestated = true; } } public boolean isPregnant() { return gestated; }
if (isPregnant() = true) { gestationPeriod(); }
if (isPregnant()) { gestationPeriod(); }
if (isPregnant() == true) { gestationPeriod(); }