Class World<E>

java.lang.Object
  extended by World<E>

public class World<E>
extends Object

This module includes the functions 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 have type E.

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

There are many ways to implement this structure. HINT: look at the structure.Matrix class. You should need to add no more than about ten lines of code to this file.


Constructor Summary
World(int w, int h)
          This function creates a new world consisting of width columns and height rows, each of which is numbered beginning at 0.
 
Method Summary
 E get(Position pos)
          Return the contents of a position on the board.
 int height()
          Returns the height of the world.
 void set(Position pos, E c)
          Set a position on the board to contain c.
 int width()
          Returns the width of the world.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

World

public World(int w,
             int h)
This function creates a new world consisting of width columns and height rows, each of which is numbered beginning at 0. A newly created world contains no objects.

Method Detail

height

public int height()
Returns the height of the world.


width

public int width()
Returns the width of the world.


set

public void set(Position pos,
                E c)
Set a position on the board to contain c.


get

public E get(Position pos)
Return the contents of a position on the board.