|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Map
public class Map
This class creates a map of locations which represents the game board for Oregon Trail
Field Summary | |
---|---|
private double |
depotDensity
The density of the number of Depots on the map |
private double |
forestDensity
The density of the number of forests on the map. |
private Location[][] |
map
The 2d array of locations in the map, indexed by row-col coordinates. |
private double |
mountainDensity
The density of the number of mountains on the map. |
Constructor Summary | |
---|---|
Map()
Default constructor. |
|
Map(int height,
int width)
This constructor initializes a 2D map of null Location references using the values specified by height and width as row and column dimensions, if they are positive. |
|
Map(int height,
int width,
double theDepotDensity,
double theForestDensity,
double theMountainDensity)
This specific constructor initializes the 2D map using the given height and width parameters, if positive, as the row and column dimensions. |
Method Summary | |
---|---|
double |
getDepotDensity()
Returns the value of the private data member depotDensity |
double |
getForestDensity()
Returns the value of the private data member forestDensity |
Location |
getLocationAt(int row,
int col)
Returns the location at the coordinates specified by row and col. |
Location[][] |
getMap()
Returns the 2-D private data member map |
double |
getMountainDensity()
Returns the value of the private data member mountainDensity. |
int |
getNumCols()
Returns the number of columns on the map. |
int |
getNumRows()
Returns the number of rows on the Map. |
void |
populate()
This method takes care of populating the map. |
void |
setDepotDensity(double theDepotDensity)
Sets the depotDensity property to the value passed. |
void |
setForestDensity(double theForestDensity)
Sets the forestDensity property to the value passed. |
void |
setLocationAt(int row,
int col,
Location loc)
Sets the map location at the coordinates specified by row and col (if valid) to the passed Location, loc. |
void |
setMap(Location[][] map)
Sets the private 2-D map array to the 2-D map that is passed as a parameter. |
void |
setMountainDensity(double theMountainDensity)
Sets the mountainDensity property to the parameter value passed. |
void |
setPriceFactors()
Sets the price factors for each Depot that exists on the map. |
void |
setVisibility(int row,
int col,
int visibility)
Sets the isVisited flag to true for all the locations within visibility distance from the location specified by row and col. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Location[][] map
private double depotDensity
private double forestDensity
private double mountainDensity
Constructor Detail |
---|
public Map()
Game.BOARD_HEIGHT
and Game.BOARD_WIDTH
as dimensions.
After the constructor is executed, the map will contain BOARD_HEIGHT
by BOARD_WIDTH null Location references.
public Map(int height, int width)
height
- The height of the mapwidth
- The width of the mappublic Map(int height, int width, double theDepotDensity, double theForestDensity, double theMountainDensity)
height
- The height of the mapwidth
- The width of the maptheDepotDensity
- The density value for Depots. Must be greater than 0.0.theForestDensity
- The density value for Forests. Must be greater than 0.0.theMountainDensity
- The density value for Mountains. Must be greater than 0.0.Method Detail |
---|
public double getDepotDensity()
public void setDepotDensity(double theDepotDensity)
Game.DEPOT_CHANCE
.
theDepotDensity
- The depotDensity to set.public double getForestDensity()
public void setForestDensity(double theForestDensity)
Game.DENSITY_FOREST
.
theForestDensity
- The forestDensity to set.public Location[][] getMap()
public void setMap(Location[][] map)
map
- The map to set.public double getMountainDensity()
public void setMountainDensity(double theMountainDensity)
Game.DENSITY_MOUNTAIN
.
theMountainDensity
- The mountainDensity to set.public int getNumCols()
public int getNumRows()
public void setLocationAt(int row, int col, Location loc)
row
- The row of the location in the mapcol
- The column of the location in the maploc
- The location to setpublic Location getLocationAt(int row, int col)
row
- The row of the location in the mapcol
- The column of the location in the map
public void setVisibility(int row, int col, int visibility)
row
- The row positioncol
- The column positionvisibility
- The number of squares of visibility that
can be seen beyond those that have been visited.public void populate()
public void setPriceFactors()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |