com.rubecula.darwin.domain.world
Class Mate
java.lang.Object
net.sf.tostring0.AToString
com.rubecula.darwin.domain.world.Mate
- All Implemented Interfaces:
- net.sf.tostring0.IToString
public class Mate
- extends net.sf.tostring0.AToString
Class to model a potential (male) mate. Objects of this class are used to
choose the best male as a mate for a female.
- Author:
- Robin Hillyard
Fields inherited from interface net.sf.tostring0.IToString |
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE |
Method Summary |
static Mate |
createMate(Organism male,
double desirability)
Factory method to create a new Mate object based on the given
male Organism and his desirability . |
static Mate |
createNemo(double minimumDesirability)
|
double |
getDesirability()
|
Organism |
getMale()
|
boolean |
updateIfBetter(Mate candidate)
Update this object according to candidate male and desirability,
providing that the candidate desirability is greater than the current
value (and that the candidate male is not null). |
Methods inherited from class net.sf.tostring0.AToString |
toString, toString, toStringBrief, toStringId |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
createMate
public static Mate createMate(Organism male,
double desirability)
- Factory method to create a new
Mate
object based on the given
male
Organism and his desirability
.
- Parameters:
male
- the male organism who will be our mate.desirability
- the mate's desirability.
- Returns:
- a newly constructed Mate object based on the given male and
desirability
createNemo
public static Mate createNemo(double minimumDesirability)
- Parameters:
minimumDesirability
- the minimum acceptable desirability for a real Mate
.
- Returns:
- a null Mate used only for comparison purposes (every real
candidate
Mate
with better than the minimum desirability
will be better than this one.
getDesirability
public double getDesirability()
- Returns:
- the desirability
getMale
public Organism getMale()
- Returns:
- the (male) mate
updateIfBetter
public boolean updateIfBetter(Mate candidate)
- Update this object according to candidate male and desirability,
providing that the candidate desirability is greater than the current
value (and that the candidate male is not null).
- Parameters:
candidate
- the candidate Mate (may be null in which case nothing will
happen)
- Returns:
- true if this was updated to equal the candidate.
Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.