darwin.domain
Interface World

All Known Implementing Classes:
MyWorld

public interface World

This interface includes the methods necessary to keep track of the creatures in a two-dimensional world. In order for the design to be general, the interface adopts the following design:

1. The contents are unspecified objects.

2. The dimensions of the world array are specified by the client.

There are many ways to implement this interface. You should need to add no more than about ten lines of code to the implementation.


Method Summary
 java.lang.Object get(java.awt.Point aPosition)
          Determine the contents of a position in this World.
 int getHeight()
          Determine the height of this World.
 int getWidth()
          Determine the width of this World.
 boolean inRange(java.awt.Point aPosition)
          Determine whether a position is in this World or not.
 void set(java.awt.Point aPosition, java.lang.Object aObject)
          Set a position in this World to contain an Object.
 

Method Detail

get

public java.lang.Object get(java.awt.Point aPosition)
Determine the contents of a position in this World.

Parameters:
aPosition - a non-null position in this World.
Returns:
the Object at aPosition in this World.

getHeight

public int getHeight()
Determine the height of this World.

Returns:
the height of this World.

getWidth

public int getWidth()
Determine the width of this World.

Returns:
the width of this World.

inRange

public boolean inRange(java.awt.Point aPosition)
Determine whether a position is in this World or not.

Parameters:
aPosition - a non-null position.
Returns:
true if aPosition is an (x,y) location in the bounds of this World.

set

public void set(java.awt.Point aPosition,
                java.lang.Object aObject)
Set a position in this World to contain an Object.

Parameters:
aPosition - a non-null position in this World.
aObject - the Object to place at aPosition. aObject may be null.