Modifier and Type | Field and Description |
---|---|
private int |
age
The age of an oceanobject.
|
protected int[] |
direction
The direction is like a movement vector.
|
private int |
hunger
The hunger.
|
private javax.swing.ImageIcon |
icon
The icon of an ocean object.
|
private int |
ID
The id is the final identifier.
|
protected static int |
KEINE_KOLLISION
The Constant KEINE_KOLLISION.
|
protected static int |
KOLLISION_LINKS
The Constant KOLLISION_LINKS.
|
protected static int |
KOLLISION_OBEN
The Constant KOLLISION_OBEN.
|
protected static int |
KOLLISION_RECHTS
The Constant KOLLISION_RECHTS.
|
protected static int |
KOLLISION_UNTEN
The Constant KOLLISION_UNTEN.
|
private int |
maximumAge
The maximum age.
|
private OceanInterface |
myOcean
The model interface.
|
private java.lang.String |
oceanObjectName
The object's name.
|
private int[] |
position
The current position.
|
protected java.util.Random |
rand
A random value for a more natural movement.
|
private static long |
serialVersionUID
The Constant serialVersionUID.
|
private java.lang.Boolean |
tagged
This attribute is 'true', when the Object is tagged.
|
protected java.lang.Boolean |
toppledLeft
This attribute is 'true' if the object lies on the left side.
|
protected java.lang.Boolean |
toppledRight
This attribute is 'true' if the object lies on the right side.
|
private int |
type
The type value describes what type of ocean object the object is (like: Fish, Stone, Bubble...)
|
protected java.lang.Boolean |
upright
This attribute is 'true', when the Object is upright.
|
private int |
xDirConst
The x-dir-const value.
|
private int |
xDirVar
The x-dir-var value.
|
private int |
yDirConst
The y-dir-const value.
|
private int |
yDirVar
The y-dir-var value.
|
Constructor and Description |
---|
OceanObject(int ID,
java.lang.String name,
int[] position,
OceanInterface ocean,
int maximumAge)
Instantiates a new OceanObject.
|
Modifier and Type | Method and Description |
---|---|
int |
collidesWithOceanBounds()
Finds out whether or not this ocean object collides with the ocean's bounds.
|
void |
crushLowerObject(OceanObject obj2)
Crush the lower object.
|
void |
decHunger()
Decrease the attribute hunger by one.
|
int |
getAge()
Gets the oceanObject age.
|
java.awt.Dimension |
getDimensionsOfIcon()
Gets the dimensions of the object's icon.
|
int[] |
getDirection()
Gets the direction.
|
java.lang.String |
getDirectionString()
Gets the direction as a string.
|
int |
getDirectionX()
Gets the direction's x-value.
|
int |
getDirectionY()
Gets the direction's y-value.
|
int |
getHunger()
Gets the hunger.
|
javax.swing.ImageIcon |
getIcon()
Gets the icon.
|
int |
getID()
Gets the oceanObject's id.
|
int |
getMaximumAge()
Gets the oceanObjects maximum age.
|
OceanInterface |
getMyOcean()
Gets the model interface.
|
java.lang.String |
getOceanObjectName()
Gets the oceanObject's name.
|
int[] |
getPosition()
Gets the position in an int[2]-Array.
|
java.lang.String |
getPositionString()
Gets the position as a string.
|
int |
getPositionX()
Gets the position's x value.
|
int |
getPositionY()
Gets the position's y value.
|
java.util.Random |
getRand()
Gets the random number generator attribute.
|
java.lang.Boolean |
getTagged()
Gets the tagged attribute.
|
java.lang.Boolean |
getToppledLeft()
Gets the toppled-left attribute.
|
java.lang.Boolean |
getToppledRight()
Gets the toppled-right attribute.
|
int |
getType()
Gets the type.
|
java.lang.Boolean |
getUpright()
Gets the upright attribute.
|
int |
getxDirConst()
Gets the x-dir-const value.
|
int |
getxDirVar()
Gets the x-dir-var value.
|
int |
getyDirConst()
Gets the y-dir-const value.
|
int |
getyDirVar()
Gets the y-dir-var value.
|
void |
incHunger()
Increases the hunger attribute.
|
void |
meBounce(OceanObject obj2)
Me bounce.
|
int |
move()
The move method adds the adds the new direction the the current
position (move) and updates the ocean objects image.
|
java.lang.Boolean |
movementCollisionTwo(OceanObject obj2)
Movement collision two.
|
abstract void |
reaktion(OceanObject obj2)
This method describes the reaction of an object with a second object.
|
java.lang.Boolean |
RectangleIntersect(OceanObject obj2)
This method detects a collision of two objects.
|
void |
setAge(int age)
Sets the age of the oceanObject.
|
void |
setDirection(int[] direction)
Sets the direction of the oceanObject.
|
void |
setDirectionX(int directionX)
Sets the direction's x value.
|
void |
setDirectionY(int directionY)
Sets the direction's y value.
|
void |
setHunger(int hunger)
Sets the hunger of the oceanObject.
|
void |
setIcon(javax.swing.ImageIcon icon)
Sets the objects icon.
|
void |
setIcon(java.lang.String filename)
Sets the object's icon.
|
void |
setID(int ID)
Sets the object's id.
|
void |
setMaximumAge(int maximumAge)
Sets the maximum age.
|
void |
setMyOcean(OceanInterface myOcean)
Sets the ocean.
|
void |
setOceanObjectName(java.lang.String name)
Sets the ocean object's name.
|
void |
setPosition(int[] position)
Sets the object's position.
|
void |
setPositionX(int positionX)
Sets the object's position's x value.
|
void |
setPositionY(int positionY)
Sets the object's position's y value.
|
void |
setRand(java.util.Random rand)
Generate a new random number generator.
|
void |
setTagged(java.lang.Boolean tagged)
Sets the object's tagged attribute.
|
void |
setToppledLeft(java.lang.Boolean toppledLeft)
Sets the object's toppled-left attribute.
|
void |
setToppledRight(java.lang.Boolean toppledRight)
Sets the object's toppled-right attribute.
|
void |
setType(int type)
Sets the objects type attribute.
|
void |
setUpright(java.lang.Boolean upright)
Sets the object's upright attribute.
|
void |
setxDirConst(int xDirConst)
Sets the x-dir-const value.
|
void |
setxDirVar(int xDirVar)
Sets the x-dir-var value.
|
void |
setyDirConst(int yDirConst)
Sets the y-dir-const value.
|
void |
setyDirVar(int yDirVar)
Sets the y-dir-var value.
|
void |
topple(OceanObject obj2)
Topples the object left or right, by collision with object2.
|
void |
toppleLeft()
Topples the object left.
|
void |
toppleRight()
Topples the object right.
|
java.lang.String |
toString() |
protected abstract void |
updateDirectionWhenCollidingWithOceanBounds(int collision)
Updates the object's direction when colliding with ocean bounds.
|
private void |
updateImageWhenMoving()
Updates the image when moving.
|
void |
youBounce(OceanObject obj2)
You bounce.
|
protected static final int KEINE_KOLLISION
protected static final int KOLLISION_LINKS
protected static final int KOLLISION_OBEN
protected static final int KOLLISION_RECHTS
protected static final int KOLLISION_UNTEN
private static final long serialVersionUID
private int age
protected int[] direction
private int hunger
private javax.swing.ImageIcon icon
private int ID
private int maximumAge
private OceanInterface myOcean
private java.lang.String oceanObjectName
private int[] position
protected java.util.Random rand
private java.lang.Boolean tagged
protected java.lang.Boolean toppledLeft
protected java.lang.Boolean toppledRight
private int type
protected java.lang.Boolean upright
private int xDirConst
private int xDirVar
private int yDirConst
private int yDirVar
public OceanObject(int ID, java.lang.String name, int[] position, OceanInterface ocean, int maximumAge) throws java.lang.Exception
ID
- the idname
- the nameposition
- the positionocean
- the oceanmaximumAge
- the maximum agejava.lang.Exception
- the exceptionpublic void decHunger()
public int getAge()
public java.awt.Dimension getDimensionsOfIcon()
public int[] getDirection()
public java.lang.String getDirectionString()
public int getDirectionX()
public int getDirectionY()
public int getHunger()
public javax.swing.ImageIcon getIcon()
public int getID()
public int getMaximumAge()
public OceanInterface getMyOcean()
public java.lang.String getOceanObjectName()
public int[] getPosition()
public java.lang.String getPositionString()
public int getPositionX()
public int getPositionY()
public java.util.Random getRand()
public java.lang.Boolean getTagged()
public java.lang.Boolean getToppledLeft()
public java.lang.Boolean getToppledRight()
public int getType()
public java.lang.Boolean getUpright()
public int getxDirConst()
public int getxDirVar()
public int getyDirConst()
public int getyDirVar()
public void incHunger()
public int collidesWithOceanBounds()
public void crushLowerObject(OceanObject obj2)
obj2
- the other objectpublic void meBounce(OceanObject obj2)
obj2
- is the second object in the collisionpublic int move()
public java.lang.Boolean movementCollisionTwo(OceanObject obj2)
obj2
- the obj2public abstract void reaktion(OceanObject obj2)
obj2
- is the second object in the collisionpublic java.lang.Boolean RectangleIntersect(OceanObject obj2)
obj2
- is the second object in the collisionpublic void setAge(int age)
age
- the age to setpublic void setDirection(int[] direction)
direction
- the direction to setpublic void setID(int ID)
ID
- the iD to setpublic void setMaximumAge(int maximumAge)
maximumAge
- the maximumAge to setpublic void setMyOcean(OceanInterface myOcean)
myOcean
- the ocean to setpublic void setOceanObjectName(java.lang.String name)
name
- the new namepublic void setPosition(int[] position)
position
- the position to setpublic void setPositionX(int positionX)
positionX
- the new position's x valuepublic void setPositionY(int positionY)
positionY
- position's y value.public void setRand(java.util.Random rand)
rand
- the random number generator to setpublic void setTagged(java.lang.Boolean tagged)
tagged
- whether or not the object is taggedpublic void setToppledLeft(java.lang.Boolean toppledLeft)
toppledLeft
- whether or not the object is toppled leftpublic void setToppledRight(java.lang.Boolean toppledRight)
toppledRight
- whether or not the object is toppled rightpublic void setType(int type)
type
- the type to setpublic void setUpright(java.lang.Boolean upright)
upright
- whether or not the object is uprightpublic void setxDirConst(int xDirConst)
xDirConst
- the xDirConst to setpublic void setxDirVar(int xDirVar)
xDirVar
- the xDirVar to setpublic void setyDirConst(int yDirConst)
yDirConst
- the yDirConst to setpublic void setyDirVar(int yDirVar)
yDirVar
- the yDirVar to setpublic void setDirectionX(int directionX)
directionX
- the new direction's x valuepublic void setDirectionY(int directionY)
directionY
- the new direction's y valuepublic void setHunger(int hunger)
hunger
- the hunger to setpublic void setIcon(javax.swing.ImageIcon icon)
icon
- the icon to setpublic void setIcon(java.lang.String filename)
filename
- the new icon's file namepublic void topple(OceanObject obj2)
obj2
- the object this object collides withpublic void toppleLeft()
public void toppleRight()
public java.lang.String toString()
toString
in class java.lang.Object
protected abstract void updateDirectionWhenCollidingWithOceanBounds(int collision)
collision
- an integer specifying which bound, if any, the object has collided withprivate void updateImageWhenMoving()
public void youBounce(OceanObject obj2)
obj2
- the second object