|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectppJava.serie04.oceanlife.Ocean
public class Ocean
Ocean: Management of a LinkedList of OceanObjects
OceanInterface
Field Summary | |
---|---|
private int |
depth
|
private static java.util.logging.Logger |
logger
|
private java.util.LinkedList<OceanObject> |
oceanObjects
|
private int |
width
|
Constructor Summary | |
---|---|
Ocean(int width,
int depth,
java.util.LinkedList<OceanObject> oceanObjects)
Constructor for an ocean with bounds and a already defined linked list of oceanObjects which can be null |
Method Summary | |
---|---|
void |
addOceanObject(OceanObject oceanObject)
Appends an oceanObject to the list |
int |
calcAbsDistance(int[] pos1,
int[] pos2)
|
void |
clearObjectList()
clears the linked list of oceanObjects |
boolean |
emptyOcean()
|
int |
getDepth()
Returns depth of ocean in pixels |
java.util.LinkedList<OceanObject> |
getOceanObjects()
Returns a linked list of all OceanObjects |
int |
getWidth()
Returns depth of ocean in pixels |
int |
indexOfNearestObject(int[] position)
Compute the next item to a specific position |
OceanInterface |
loadOcean(java.lang.String filename)
Reads and deserialize an objectStream from file |
void |
removeOceanObject(int index)
Removes an oceanObject at a specific position (index) |
void |
saveOcean(java.lang.String filename)
Serialize and write all oceanObjects to a file |
void |
setDepth(int depth)
Set the depth of ocean |
void |
setOceanObjects(java.util.LinkedList<OceanObject> oceanObjects)
Sets a list of OceanObjects |
void |
setWidth(int width)
Set the width of ocean |
java.lang.String |
toString()
Returns a readable output |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static java.util.logging.Logger logger
private int width
private int depth
private java.util.LinkedList<OceanObject> oceanObjects
Constructor Detail |
---|
public Ocean(int width, int depth, java.util.LinkedList<OceanObject> oceanObjects) throws OceanException
width
- depth
- oceanObjects
- - a list of OceanObjects
OceanException
- - i.e. invalid listMethod Detail |
---|
public boolean emptyOcean()
public java.util.LinkedList<OceanObject> getOceanObjects()
OceanInterface
getOceanObjects
in interface OceanInterface
public int getDepth()
OceanInterface
getDepth
in interface OceanInterface
public int getWidth()
OceanInterface
getWidth
in interface OceanInterface
public void setDepth(int depth)
OceanInterface
setDepth
in interface OceanInterface
public void setWidth(int width) throws OceanException
OceanInterface
setWidth
in interface OceanInterface
OceanException
- - if width is invalidpublic void clearObjectList()
LinkedList
public void setOceanObjects(java.util.LinkedList<OceanObject> oceanObjects)
OceanInterface
setOceanObjects
in interface OceanInterface
public void addOceanObject(OceanObject oceanObject) throws OceanException
OceanInterface
addOceanObject
in interface OceanInterface
OceanException
- - if data of oceanObject is invalid (i.e. position)public int calcAbsDistance(int[] pos1, int[] pos2)
public int indexOfNearestObject(int[] position) throws OceanException
OceanInterface
indexOfNearestObject
in interface OceanInterface
OceanException
public void removeOceanObject(int index) throws java.lang.IllegalArgumentException
OceanInterface
removeOceanObject
in interface OceanInterface
java.lang.IllegalArgumentException
public OceanInterface loadOcean(java.lang.String filename) throws java.lang.ClassNotFoundException, java.io.IOException
OceanInterface
loadOcean
in interface OceanInterface
java.lang.ClassNotFoundException
java.io.IOException
public void saveOcean(java.lang.String filename) throws java.io.IOException
OceanInterface
saveOcean
in interface OceanInterface
java.io.IOException
public java.lang.String toString()
OceanInterface
toString
in interface OceanInterface
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |