|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectUniverse
public class Universe
This class creates a universe of locations
| Field Summary | |
|---|---|
private double |
density
The density of the universe. |
private Location[][] |
universe
The 2d array of locations in the universe, indexed by row-col coordinates. |
| Constructor Summary | |
|---|---|
Universe()
The default constructor, it initializes the Universe to default values. |
|
Universe(int height,
int width,
double density)
The specific constructor, in initializes the fields to the passed values. |
|
| Method Summary | |
|---|---|
Location |
findLocationByName(java.lang.String dest)
Finds and returns the location specified by the location name passed |
double |
getDensity()
Get the Density value. |
Location |
getLocationAt(int row,
int col)
Gets the location at the position specified by the int values passed |
int |
getNumCols()
Returns the width of the Universe |
int |
getNumRows()
Returns the height of the Universe |
Location |
getRandomLocation()
Randomly chooses a location to return |
Location[][] |
getUniverse()
Get the Universe value. |
void |
populate()
Creates different and new locations, and place at positions in the universe depending on the universe density |
void |
setDensity(double newDensity)
Set the Density value. |
void |
setLocationAt(int row,
int col,
Location loc)
Sets the location at the specified coordinates to the passed value |
void |
setUniverse(Location[][] newUniverse)
Set the Universe value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Location[][] universe
private double density
| Constructor Detail |
|---|
public Universe(int height,
int width,
double density)
height - The height of the universewidth - The width of the universedensity - the density of the universepublic Universe()
| Method Detail |
|---|
public double getDensity()
public void setDensity(double newDensity)
newDensity - The new Density value.public Location[][] getUniverse()
public void setUniverse(Location[][] newUniverse)
newUniverse - The new Universe value.public int getNumCols()
public int getNumRows()
public void setLocationAt(int row,
int col,
Location loc)
row - The row of the location in the universecol - The column of the location in the universeloc - The location to setpublic void populate()
public Location getLocationAt(int row,
int col)
row - The row of the location in the universecol - The column of the location in the universe
public Location getRandomLocation()
public Location findLocationByName(java.lang.String dest)
dest - the name of the location to find and return
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||