Class Location

java.lang.Object
  extended by Location

public class Location
extends java.lang.Object


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

appearance

private java.lang.String appearance
The name of the location. Default value is "blank"


depot

private Depot depot
The Depot belonging to the location. Default value is null. (no depot)


posRow

private int posRow
Row coordinate of the Location. Default value is 0.


posCol

private int posCol
Column coordinate of the Location. Default value is 0.


terrainType

private int terrainType
Terrain type. Initial terrain type is Game.TERRAIN_UNSET


isVisited

private boolean isVisited
Flag indicating whether the location has been visited before. Default value is false.

Constructor Detail

Location

public Location()
Default constructor. Initializes the Location's terrain type to a random terrain type, the appearance to a randomly chosen terrain adjective by calling Descriptions.generateRandomTerrainAdjective(), and creates a new Depot if a randomly generated double is less than Game.DEPOT_CHANCE


Location

public Location(int r,
                int c)
Specific two-parameter constructor. Performs all the same actions that Location() performs, then sets posRow to r and posCol to c


Location

public Location(int terrain,
                int r,
                int c,
                java.lang.String app,
                Depot dep)
Specific five-parameter constructor. Performs all the same actions that Location() performs, then sets

Method Detail

getAppearance

public java.lang.String getAppearance()
Returns:
Returns the appearance.

setAppearance

public void setAppearance(java.lang.String appearance)
Parameters:
appearance - The appearance to set.

getDepot

public Depot getDepot()
Returns:
Returns the depot.

setDepot

public void setDepot(Depot depot)
Parameters:
depot - The depot to set.

getPosRow

public int getPosRow()
Returns:
Returns the posRow.

setPosRow

public void setPosRow(int posRow)
Parameters:
posRow - The posRow to set.

getPosCol

public int getPosCol()
Returns:
Returns the posCol.

setPosCol

public void setPosCol(int posCol)
Parameters:
posCol - The posCol to set.

getTerrainType

public int getTerrainType()
Returns:
Returns the terrainType.

setTerrainType

public void setTerrainType(int terrainType)
Parameters:
terrainType - The terrainType to set.

getIsVisited

public boolean getIsVisited()
Returns:
Returns the value of isVisited.

setIsVisited

public void setIsVisited(boolean isVisited)
Sets isVisited field to the value passed

Parameters:
isVisited -

getTerrainMovementCost

public double getTerrainMovementCost()
Returns the cost of moving across the Location's terrain type. Terrain movement costs are specified by Game constants: Game.MOVEMENT_COST_MOUNTAIN, Game.MOVEMENT_COST_FOREST, and Game.MOVEMENT_COST_GRASSLAND. Otherwise, an error code of -1.0 is returned.

Returns:
The cost of moving across the terrain type.

toString

public java.lang.String toString()
The method which prints a Location.

Overrides:
toString in class java.lang.Object
Returns:
A string that contains the appearance, the name of the terrain type, the row and column coordinates and whether or not a depot is present at the Location.

chooseTerrainType

private void chooseTerrainType()
Chooses a random terrain type based on a random number, of type double, generated from 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.