📄 squareenvironment.html
字号:
</TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="SquareEnvironment()"><!-- --></A><H3>SquareEnvironment</H3><PRE>public <B>SquareEnvironment</B>()</PRE><DL><DD>Constructs a <code>SquareEnvironment</code> object in which cells have four adjacent neighbors -- those with which they share sides. These neighbors are in the four cardinal directions.</DL><HR><A NAME="SquareEnvironment(boolean)"><!-- --></A><H3>SquareEnvironment</H3><PRE>public <B>SquareEnvironment</B>(boolean includeDiagonalNeighbors)</PRE><DL><DD>Constructs a <code>SquareEnvironment</code> object in which cells have four or eight adjacent neighbors, depending on the value of the <code>includeDiagonalNeighbors</code> parameter. If <code>includeDiagonalNeighbors</code> is <code>true</code>, cells have eight adjacent neighbors -- the immediately adjacent neighbors on all four sides and the four neighbors on the diagonals. If <code>includeDiagonalNeighbors</code> is <code>false</code>, cells have only the four neighbors they would have in an environment created with the default <code>SquareEnvironment</code> constructor.<DD><DL><DT><B>Parameters:</B><DD><CODE>includedDiagonalNeighbors</CODE> - whether to include the four diagonal locations as neighbors</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="numCellSides()"><!-- --></A><H3>numCellSides</H3><PRE>public int <B>numCellSides</B>()</PRE><DL><DD>Returns the number of sides around each cell.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#numCellSides()">numCellSides</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of cell sides in this environment</DL></DD></DL><HR><A NAME="numAdjacentNeighbors()"><!-- --></A><H3>numAdjacentNeighbors</H3><PRE>public int <B>numAdjacentNeighbors</B>()</PRE><DL><DD>Returns the number of adjacent neighbors around each cell.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#numAdjacentNeighbors()">numAdjacentNeighbors</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of adjacent neighbors</DL></DD></DL><HR><A NAME="randomDirection()"><!-- --></A><H3>randomDirection</H3><PRE>public <A HREF="Direction.html">Direction</A> <B>randomDirection</B>()</PRE><DL><DD>Generates a random direction. The direction returned by <code>randomDirection</code> reflects the direction from a cell in the environment to one of its adjacent neighbors.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#randomDirection()">randomDirection</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a direction</DL></DD></DL><HR><A NAME="getDirection(Location, Location)"><!-- --></A><H3>getDirection</H3><PRE>public <A HREF="Direction.html">Direction</A> <B>getDirection</B>(<A HREF="Location.html">Location</A> fromLoc, <A HREF="Location.html">Location</A> toLoc)</PRE><DL><DD>Returns the direction from one location to another. If <code>fromLoc</code> and <code>toLoc</code> are the same, <code>getDirection</code> arbitrarily returns <code>Direction.NORTH</code>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#getDirection(Location, Location)">getDirection</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>fromLoc</CODE> - starting location for search<DD><CODE>toLoc</CODE> - destination location<DT><B>Returns:</B><DD>direction from <code>fromLoc</code> to <code>toLoc</code></DL></DD></DL><HR><A NAME="getNeighbor(Location, Direction)"><!-- --></A><H3>getNeighbor</H3><PRE>public <A HREF="Location.html">Location</A> <B>getNeighbor</B>(<A HREF="Location.html">Location</A> fromLoc, <A HREF="Direction.html">Direction</A> compassDir)</PRE><DL><DD>Returns the adjacent neighbor (whether valid or invalid) of a location in the specified direction.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#getNeighbor(Location, Direction)">getNeighbor</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>fromLoc</CODE> - starting location for search<DD><CODE>compassDir</CODE> - direction in which to look for adjacent neighbor<DT><B>Returns:</B><DD>neighbor of <code>fromLoc</code> in given direction (whether valid or not)</DL></DD></DL><HR><A NAME="neighborsOf(Location)"><!-- --></A><H3>neighborsOf</H3><PRE>public java.util.ArrayList <B>neighborsOf</B>(<A HREF="Location.html">Location</A> ofLoc)</PRE><DL><DD>Returns the adjacent neighbors of a specified location. Only neighbors that are valid locations in the environment will be included.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="Environment.html#neighborsOf(Location)">neighborsOf</A></CODE> in interface <CODE><A HREF="Environment.html">Environment</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>ofLoc</CODE> - location whose neighbors to get<DT><B>Returns:</B><DD>a list of locations that are neighbors of <code>ofLoc</code></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>AP® Computer Science Marine Biology Simulation</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="SlowFish.html"><B>PREV CLASS</B></A> <A HREF="UnboundedEnv.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="SquareEnvironment.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><i>Copyright© 2002 College Entrance Examination Board</i></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -