|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Location
public class Location
Field Summary | |
---|---|
private java.lang.String |
appearance
The name of the location. |
private Depot |
depot
The Depot belonging to the location. |
private boolean |
isVisited
Flag indicating whether the location has been visited before. |
private int |
posCol
Column coordinate of the Location. |
private int |
posRow
Row coordinate of the Location. |
private int |
terrainType
Terrain type. |
Constructor Summary | |
---|---|
Location()
Default constructor. |
|
Location(int r,
int c)
Specific two-parameter constructor. |
|
Location(int terrain,
int r,
int c,
java.lang.String app,
Depot dep)
Specific five-parameter constructor. |
Method Summary | |
---|---|
private void |
chooseTerrainType()
Chooses a random terrain type based on a random number, of type double, generated from Game.random . |
java.lang.String |
getAppearance()
|
Depot |
getDepot()
|
boolean |
getIsVisited()
|
int |
getPosCol()
|
int |
getPosRow()
|
double |
getTerrainMovementCost()
Returns the cost of moving across the Location's terrain type. |
int |
getTerrainType()
|
void |
setAppearance(java.lang.String appearance)
|
void |
setDepot(Depot depot)
|
void |
setIsVisited(boolean isVisited)
Sets isVisited field to the value passed |
void |
setPosCol(int posCol)
|
void |
setPosRow(int posRow)
|
void |
setTerrainType(int terrainType)
|
java.lang.String |
toString()
The method which prints a Location. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String appearance
private Depot depot
private int posRow
private int posCol
private int terrainType
Game.TERRAIN_UNSET
private boolean isVisited
Constructor Detail |
---|
public Location()
Descriptions.generateRandomTerrainAdjective()
,
and creates a new Depot if a randomly generated double is less than Game.DEPOT_CHANCE
public Location(int r, int c)
Location()
performs, then sets posRow to r and posCol to c
public Location(int terrain, int r, int c, java.lang.String app, Depot dep)
Location()
performs, then sets
Method Detail |
---|
public java.lang.String getAppearance()
public void setAppearance(java.lang.String appearance)
appearance
- The appearance to set.public Depot getDepot()
public void setDepot(Depot depot)
depot
- The depot to set.public int getPosRow()
public void setPosRow(int posRow)
posRow
- The posRow to set.public int getPosCol()
public void setPosCol(int posCol)
posCol
- The posCol to set.public int getTerrainType()
public void setTerrainType(int terrainType)
terrainType
- The terrainType to set.public boolean getIsVisited()
public void setIsVisited(boolean isVisited)
isVisited
- public double getTerrainMovementCost()
Game.MOVEMENT_COST_MOUNTAIN
, Game.MOVEMENT_COST_FOREST
,
and Game.MOVEMENT_COST_GRASSLAND
. Otherwise, an error code of -1.0 is returned.
public java.lang.String toString()
toString
in class java.lang.Object
private void chooseTerrainType()
Game.random
.
If the random number is less than Game.DENSITY_FOREST
, then the
terrain type is set to forest. Otherwise, if the random value is between
Game.DENSITY_FOREST
and Game.DENSITY_MOUNTAIN
, then set terrain
type to mountain.
Otherwise, set terrain type to grassland.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |