|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.SwingWorker<java.lang.String,java.lang.String>
com.avian.birds.basebirds.AbstractBasicBird
com.avian.birds.basebirds.StdBird
com.avian.birds.philos.Phil2
public class Phil2
A type of StdBird that is good at philosophizing but not so good at chatting. Each philosopher shares forks with the philosophers seated at both sides. The philosophers try to pick up the fork to their left and then try to get the fork to their right.
Rules:
Philosophers can only eat when they have both left and right forks.
When they has both forks, they eat for a random length of time and then put down both forks.
When they get the left fork, they try to pick up the righthand fork x number of times, where x is the number set in variable "getForkTries" (default is 3). This is an Xmv variable. On the Activity tab for each bird, you can set the number of times that each philosopher will try before giving up and putting down the left fork.
If a philosopher cannot get the righthand fork after x tries, they put down the lefthand fork and then waits for a random length of time before trying again.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.SwingWorker |
---|
javax.swing.SwingWorker.StateValue |
Field Summary | |
---|---|
java.lang.String |
getForkTries
Number of times this philosopher bird will try to get the second fork. |
Fields inherited from class com.avian.birds.basebirds.StdBird |
---|
foodFromTree, healthStatus, jbRefStart, jlRefLastAte, jtaRefHistory, jtfRefHealth, mts, myTupleTree, nts, sampleXmv, startButtonText |
Fields inherited from class com.avian.birds.basebirds.AbstractBasicBird |
---|
bhf, bif, birdDesc, birdHistory, birdName, bof, eatsFood, hatchTime, historyFileName, inputFileName, lastAte, levelOfInfo, lifeTime, napLength, outputFileName, stamina, stopNow, storesFood |
Constructor Summary | |
---|---|
Phil2()
|
Method Summary | |
---|---|
void |
digest()
Provides the processing functionality for this Bird. |
void |
eatFood()
Every Philosopher Bird must eat food to stay alive and this method provides the instructions that this Bird will follow to eat. |
void |
setGetForkTries(java.lang.String getForkTries)
Setter that takes the value that was set on screen in Aviary and uses it to set the number of times that this philosopher bird will try to get second fork. |
void |
storeFood()
Need to put back any forks that we are holding |
Methods inherited from class com.avian.birds.basebirds.StdBird |
---|
checkAge, done, setHealthRef, setHealthStatus, setHistoryAreaRef, setJlRefLastAte, setStartButtonRef, setStartButtonText, setTupleTree |
Methods inherited from class com.avian.birds.basebirds.AbstractBasicBird |
---|
addToBirdHistory, doInBackground, getAuxFood, getBirdDescription, getBirdHistory, getBirdName, getEatsFood, getHatchTime, getHistoryFileName, getInputFileName, getLastAte, getLevelOfInfo, getLifeTime, getNameOfFoodToStore, getNapLength, getOutputFileName, getStamina, isStopNow, setBhf, setBif, setBirdDesc, setBirdHistory, setBirdName, setBof, setEatsFood, setHatchTime, setHistoryFileName, setInputFileName, setLevelOfInfo, setLevelOfInfo, setLifeTime, setNapLength, setOutputFileName, setStamina, setStopNow, setStoresFood |
Methods inherited from class javax.swing.SwingWorker |
---|
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.lang.String getForkTries
Constructor Detail |
---|
public Phil2()
Method Detail |
---|
public void setGetForkTries(java.lang.String getForkTries)
getForkTries
- is the int number of times that the philosopher bird will
try to get the second fork. This value comes from Integer.parseInt() that
will throw a NumberFormatException if a non-numeric value is passed as the parampublic void eatFood()
eatFood
in class StdBird
public void digest()
digest
in class StdBird
public void storeFood()
storeFood
in class StdBird
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |