ppJava.serie04.oceanlife
Interface OceanInterface

All Known Implementing Classes:
Ocean

public interface OceanInterface

OceanInterface - Interface for simulating and manipulating an Ocean - get/set for bounds of Ocean - get/set for linkedList of OceanObjects - append/remove for linkedList of OceanObjects - compute the next item at a specific position - method for a readable output of Ocean and OceanObjects


Method Summary
 void addOceanObject(OceanObject oceanObject)
          Appends an oceanObject to the list
 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
 

Method Detail

getWidth

int getWidth()
Returns depth of ocean in pixels

Returns:
width of ocean in pixels

setWidth

void setWidth(int width)
              throws OceanException
Set the width of ocean

Parameters:
width -
Throws:
OceanException - - if width is invalid

getDepth

int getDepth()
Returns depth of ocean in pixels

Returns:
depth of ocean in pixels

setDepth

void setDepth(int depth)
              throws OceanException
Set the depth of ocean

Parameters:
depth -
Throws:
OceanException - - if depth is invalid

getOceanObjects

java.util.LinkedList<OceanObject> getOceanObjects()
Returns a linked list of all OceanObjects

Returns:
a linked list of all OceanObjects (null if empty)

setOceanObjects

void setOceanObjects(java.util.LinkedList<OceanObject> oceanObjects)
Sets a list of OceanObjects

Parameters:
oceanObjects -

addOceanObject

void addOceanObject(OceanObject oceanObject)
                    throws OceanException
Appends an oceanObject to the list

Parameters:
oceanObject -
Throws:
OceanException - - if data of oceanObject is invalid (i.e. position)

removeOceanObject

void removeOceanObject(int index)
                       throws java.lang.IllegalArgumentException
Removes an oceanObject at a specific position (index)

Parameters:
index -
Throws:
OceanException - - if index is invalid (i.e. out of bounds)
java.lang.IllegalArgumentException

indexOfNearestObject

int indexOfNearestObject(int[] position)
                         throws OceanException
Compute the next item to a specific position

Parameters:
position -
Returns:
the id of next oceanObject to the given position
Throws:
OceanException

saveOcean

void saveOcean(java.lang.String filename)
               throws java.io.IOException
Serialize and write all oceanObjects to a file

Parameters:
filename -
Throws:
java.io.IOException

loadOcean

OceanInterface loadOcean(java.lang.String filename)
                         throws java.lang.ClassNotFoundException,
                                java.io.IOException
Reads and deserialize an objectStream from file

Parameters:
filename -
Returns:
ocean with objectlist
Throws:
java.lang.ClassNotFoundException
java.io.IOException

toString

java.lang.String toString()
Returns a readable output

Overrides:
toString in class java.lang.Object
Returns:
a readable output of the ocean and its list