org.cfpm.caves.za
Class Village

java.lang.Object
  extended by org.cfpm.caves.za.Village

public class Village
extends java.lang.Object

This class represents a village in the model. It maintains its area in space so that new households can be placed within the boundaries of the village. Villages are placed randomly in space but don't overlap.

Author:
Ruth

Field Summary
(package private) static int buffer
          buffer around villages to ensure they don't overlap
(package private)  int[] extension
          bounding box of the village area on the 2D grid
(package private)  jess.Value name
          name of the village
 
Constructor Summary
Village(java.lang.String nameString, int[] centre, int radius)
          Creates a new village of the given name.
Village(java.lang.String nameString, int x0, int y0, int x1, int y1)
          Creates a new village of the given name.
 
Method Summary
 boolean covers(int x, int y)
          checks if the specified location is covered by the village
 boolean coversWithBuffer(int x, int y)
          checks if the specified location falls within the village area plus buffer.
 int[] getExtension()
          returns the village's spatial extension
 jess.Value getName()
          returns the name of the village
 void setExtension(int[] extension)
          sets the village's spatial extension (bounding box)
 void setName(java.lang.String nameString)
          sets the village's name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

static final int buffer
buffer around villages to ensure they don't overlap

See Also:
Constant Field Values

name

jess.Value name
name of the village


extension

int[] extension
bounding box of the village area on the 2D grid

Constructor Detail

Village

public Village(java.lang.String nameString,
               int[] centre,
               int radius)
Creates a new village of the given name. Its area is specified by centre and radius.

Parameters:
nameString - name of the village
centre - x,y coordinates of the centre
radius - the radius as number of cells

Village

public Village(java.lang.String nameString,
               int x0,
               int y0,
               int x1,
               int y1)
Creates a new village of the given name. Its area is specified by the bounding box.

Parameters:
nameString - name of the village
x0 - x coordinate of the "upper left" corner
y0 - y coordinate of the "upper left" corner
x1 - x coordinate of the "lower right" corner
y1 - y coordinate of the "lower right" corner
Method Detail

setExtension

public void setExtension(int[] extension)
sets the village's spatial extension (bounding box)

Parameters:
extension - the bounding box as x,y coordinates of the upper left and lower right corners

setName

public void setName(java.lang.String nameString)
sets the village's name

Parameters:
nameString - name of the village

getName

public jess.Value getName()
returns the name of the village

Returns:
the village's name

getExtension

public int[] getExtension()
returns the village's spatial extension

Returns:
bounding box as x,y coordinates of the upper left and lower right corners

covers

public boolean covers(int x,
                      int y)
checks if the specified location is covered by the village

Parameters:
x - x-coordinate
y - y-coordinate
Returns:
true if inside the village, false otherwise

coversWithBuffer

public boolean coversWithBuffer(int x,
                                int y)
checks if the specified location falls within the village area plus buffer.

Parameters:
x - x-coordinate
y - y-coordinate
Returns:
true if inside the buffered village, false otherwise