|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMonkey
public class Monkey
Constructor Summary | |
---|---|
Monkey(Sex sex,
int year)
Create a monkey instance. |
Method Summary | |
---|---|
void |
addChild(Monkey child)
This method adds a child "child" for this monkey. |
Monkey |
getDad()
|
int |
getID()
|
Monkey |
getMom()
|
int |
getNumChildren()
|
Sex |
getSex()
|
int |
getYearofbirth()
|
boolean |
isChild(Monkey child)
|
static void |
main(java.lang.String[] args)
|
void |
removeChild(Monkey child)
|
void |
setDad(Monkey dad)
|
void |
setMom(Monkey mom)
Set/replace a monkey's mom. |
static void |
stressTest()
Generates a large number monkeys with random year of births and random sex. |
static void |
testAddingRelations()
Creates a small number of monkeys, add a few relationships, and then does some basic tests. |
void |
testInvariants()
This method should contain a lot of checks using assertions that test the correctness of values and relationships in this monkey. |
static void |
testRemovingRelations()
Creates a small number of monkeys, add.removes a few relationships, and then does some basic tests. |
java.lang.String |
toString()
|
void |
unsetDad()
|
void |
unsetMom()
Remove the mom for this monkey. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Monkey(Sex sex, int year)
sex
- the sex of the new monkey. Values Monkey.Sex.M or Monkey.Sex.Fyear
- he year in which the monkey was born. A value >= 0Method Detail |
---|
public void setMom(Monkey mom)
mom
- This monkey's mom should be set to the the specified parameter.public Monkey getMom()
public void setDad(Monkey dad)
public Monkey getDad()
public void unsetMom()
public void unsetDad()
public int getID()
public boolean isChild(Monkey child)
child
-
public void addChild(Monkey child)
child
- child to be addedpublic java.lang.String toString()
toString
in class java.lang.Object
public Sex getSex()
public void testInvariants()
public void removeChild(Monkey child)
child
- This removes the specified parameter from the children's list of this monkey. It should also update the
state of the child, if necessary, so that the invariants are maintained. If the child paramter is not a child
of this monkey, this method should return without changing the state of the monkey.public int getNumChildren()
public int getYearofbirth()
public static void stressTest()
public static void testAddingRelations()
public static void testRemovingRelations()
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |