public class CokeCanBubbleGeneratorThread
extends java.lang.Thread
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private int[] |
bubblePosition
The bubble position.
|
private java.lang.Integer |
lock
The lockObject.
|
private CokeCan |
myCokeCan
The CokeCan.
|
private OceanInterface |
myOcean
The ocean.
|
private java.lang.String |
name
The name.
|
private int[] |
nozzlePosition
The nozzle position.
|
private java.util.Random |
rand
A random value generator.
|
private static long |
serialVersionUID
The Constant serialVersionUID.
|
Constructor and Description |
---|
CokeCanBubbleGeneratorThread(OceanInterface oceanInterface,
CokeCan c,
java.lang.Integer lock)
Instantiates a new coke can bubble generator thread.
|
Modifier and Type | Method and Description |
---|---|
private void |
calcNozzlePosition()
Calculates the nozzle position.
|
java.lang.String |
getCokeCanName()
Gets the CokeCan name.
|
java.lang.Integer |
getLock()
Gets the lockObject.
|
CokeCan |
getMyCokeCan()
Gets the coke can.
|
OceanInterface |
getMyOcean()
Gets the ocean.
|
int[] |
getNozzlePosition()
Gets the nozzle position.
|
private int |
getNozzlePositionX()
Gets the nozzle position's x value.
|
private int |
getNozzlePositionY()
Gets the nozzle position's y value.
|
java.util.Random |
getRand()
Gets the random number generator.
|
private void |
makeNewBubble()
Makes a new bubble with correct position.
|
void |
run()
Generates a new Bubble and lets the thread sleep for a while.
|
void |
setCokeCanName(java.lang.String name)
Sets the coke can name.
|
void |
setLock(java.lang.Integer lock)
Sets the lock.
|
void |
setMyCokeCan(CokeCan myCokeCan)
Sets the coke can.
|
void |
setMyOcean(OceanInterface myOcean)
Sets the ocean.
|
void |
setNozzlePosition(int[] nozzlePosition)
Sets the nozzle position.
|
void |
setRand(java.util.Random rand)
Sets the random number generator.
|
private void |
sleep()
Let an unspecified thread sleep.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private static final long serialVersionUID
private final int[] bubblePosition
private java.lang.Integer lock
private CokeCan myCokeCan
private OceanInterface myOcean
private java.lang.String name
private int[] nozzlePosition
private java.util.Random rand
public CokeCanBubbleGeneratorThread(OceanInterface oceanInterface, CokeCan c, java.lang.Integer lock)
oceanInterface
- the ocean interfacec
- the CokeCanlock
- the lockObjectpublic void setCokeCanName(java.lang.String name)
name
- the new coke can namepublic void setLock(java.lang.Integer lock)
lock
- the new lockpublic void setMyCokeCan(CokeCan myCokeCan)
myCokeCan
- the CokeCan to setpublic void setMyOcean(OceanInterface myOcean)
myOcean
- the ocean to setpublic void setNozzlePosition(int[] nozzlePosition)
nozzlePosition
- the nozzlePosition to setpublic void setRand(java.util.Random rand)
rand
- the random number generator to setpublic java.lang.String getCokeCanName()
public java.lang.Integer getLock()
public CokeCan getMyCokeCan()
public OceanInterface getMyOcean()
public int[] getNozzlePosition()
private int getNozzlePositionX()
private int getNozzlePositionY()
public java.util.Random getRand()
private void calcNozzlePosition()
private void makeNewBubble()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void sleep()