⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 darterfish.html

📁 java学习的好范例
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Aug 22 02:03:57 EDT 2002 --><TITLE>Marine Biology Simulation: Class  DarterFish</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>AP&reg; Computer Science Marine Biology Simulation</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="BoundedEnv.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="Debug.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>  &nbsp;&nbsp;<A HREF="DarterFish.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2>Class  DarterFish</H2><PRE>java.lang.Object  |  +--<A HREF="Fish.html">Fish</A>        |        +--<B>DarterFish</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="Locatable.html">Locatable</A></DD></DL><HR><DL><DT>public class <B>DarterFish</B><DT>extends <A HREF="Fish.html">Fish</A></DL><P>AP&reg; Computer Science Marine Biology Simulation:<br>  The <code>DarterFish</code> class represents a fish in the Marine  Biology Simulation that darts forward two spaces if it can, moves  forward one space if it  can't move two, and reverses direction  (without moving) if it cannot  move forward.  It can only "see" an  empty location two cells away if the cell in between is empty also.  In other words, if both the cell in front of the darter and the cell  in front of that cell are empty, the darter fish will move forward  two spaces.  If only the cell in front of the darter is empty, it  will move there.  If neither forward cell is empty, the fish will turn  around, changing its direction but not its location.  <p>  <code>DarterFish</code> objects inherit instance variables and much  of their behavior from the <code>Fish</code> class.  <p>  The <code>DarterFish</code> class is  copyright&copy; 2002 College Entrance Examination Board  (www.collegeboard.com).<P><DL><DT><B>Version: </B><DD>1 July 2002</DD></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="DarterFish.html#DarterFish(Environment, Location)">DarterFish</A></B>(<A HREF="Environment.html">Environment</A>&nbsp;env,           <A HREF="Location.html">Location</A>&nbsp;loc)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a darter fish at the specified location in a  given environment.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="DarterFish.html#DarterFish(Environment, Location, Direction)">DarterFish</A></B>(<A HREF="Environment.html">Environment</A>&nbsp;env,           <A HREF="Location.html">Location</A>&nbsp;loc,           <A HREF="Direction.html">Direction</A>&nbsp;dir)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a darter fish at the specified location and direction in a  given environment.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="DarterFish.html#DarterFish(Environment, Location, Direction, java.awt.Color)">DarterFish</A></B>(<A HREF="Environment.html">Environment</A>&nbsp;env,           <A HREF="Location.html">Location</A>&nbsp;loc,           <A HREF="Direction.html">Direction</A>&nbsp;dir,           java.awt.Color&nbsp;col)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a darter fish of the specified color at the specified  location and direction.</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="DarterFish.html#generateChild(Location)">generateChild</A></B>(<A HREF="Location.html">Location</A>&nbsp;loc)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a new darter fish.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="DarterFish.html#move()">move</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Moves this fish in its environment.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="Location.html">Location</A></CODE></FONT></TD><TD><CODE><B><A HREF="DarterFish.html#nextLocation()">nextLocation</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Finds this fish's next location.</TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_Fish"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class <A HREF="Fish.html">Fish</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="Fish.html#act()">act</A>, <A HREF="Fish.html#breed()">breed</A>, <A HREF="Fish.html#changeDirection(Direction)">changeDirection</A>, <A HREF="Fish.html#changeLocation(Location)">changeLocation</A>, <A HREF="Fish.html#color()">color</A>, <A HREF="Fish.html#die()">die</A>, <A HREF="Fish.html#direction()">direction</A>, <A HREF="Fish.html#emptyNeighbors()">emptyNeighbors</A>, <A HREF="Fish.html#environment()">environment</A>, <A HREF="Fish.html#id()">id</A>, <A HREF="Fish.html#isInEnv()">isInEnv</A>, <A HREF="Fish.html#location()">location</A>, <A HREF="Fish.html#randomColor()">randomColor</A>, <A HREF="Fish.html#toString()">toString</A></CODE></TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.Object</B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</CODE></TD></TR></TABLE>&nbsp;<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="DarterFish(Environment, Location)"><!-- --></A><H3>DarterFish</H3><PRE>public <B>DarterFish</B>(<A HREF="Environment.html">Environment</A>&nbsp;env,                  <A HREF="Location.html">Location</A>&nbsp;loc)</PRE><DL><DD>Constructs a darter fish at the specified location in a  given environment.   This darter is colored yellow.  (Precondition: parameters are non-null; <code>loc</code> is valid  for <code>env</code>.)<DD><DL><DT><B>Parameters:</B><DD><CODE>env</CODE> - environment in which fish will live<DD><CODE>loc</CODE> - location of the new fish in <code>env</code></DL></DD></DL><HR><A NAME="DarterFish(Environment, Location, Direction)"><!-- --></A><H3>DarterFish</H3><PRE>public <B>DarterFish</B>(<A HREF="Environment.html">Environment</A>&nbsp;env,                  <A HREF="Location.html">Location</A>&nbsp;loc,                  <A HREF="Direction.html">Direction</A>&nbsp;dir)</PRE><DL><DD>Constructs a darter fish at the specified location and direction in a  given environment.   This darter is colored yellow.  (Precondition: parameters are non-null; <code>loc</code>  is valid for <code>env</code>.)<DD><DL><DT><B>Parameters:</B><DD><CODE>env</CODE> - environment in which fish will live<DD><CODE>loc</CODE> - location of the new fish in <code>env</code><DD><CODE>dir</CODE> - direction the new fish is facing</DL></DD></DL><HR><A NAME="DarterFish(Environment, Location, Direction, java.awt.Color)"><!-- --></A><H3>DarterFish</H3><PRE>public <B>DarterFish</B>(<A HREF="Environment.html">Environment</A>&nbsp;env,                  <A HREF="Location.html">Location</A>&nbsp;loc,                  <A HREF="Direction.html">Direction</A>&nbsp;dir,                  java.awt.Color&nbsp;col)</PRE><DL><DD>Constructs a darter fish of the specified color at the specified  location and direction.  (Precondition: parameters are non-null; <code>loc</code> is valid  for <code>env</code>.)<DD><DL><DT><B>Parameters:</B><DD><CODE>env</CODE> - environment in which fish will live<DD><CODE>loc</CODE> - location of the new fish in <code>env</code><DD><CODE>dir</CODE> - direction the new fish is facing<DD><CODE>col</CODE> - color of the new fish</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="generateChild(Location)"><!-- --></A><H3>generateChild</H3><PRE>protected void <B>generateChild</B>(<A HREF="Location.html">Location</A>&nbsp;loc)</PRE><DL><DD>Creates a new darter fish.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="Fish.html#generateChild(Location)">generateChild</A></CODE> in class <CODE><A HREF="Fish.html">Fish</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>loc</CODE> - location of the new fish</DL></DD></DL><HR><A NAME="move()"><!-- --></A><H3>move</H3><PRE>protected void <B>move</B>()</PRE><DL><DD>Moves this fish in its environment.  A darter fish darts forward (as specified in <code>nextLocation</code>)  if possible, or reverses direction (without moving) if it cannot move  forward.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="Fish.html#move()">move</A></CODE> in class <CODE><A HREF="Fish.html">Fish</A></CODE></DL></DD></DL><HR><A NAME="nextLocation()"><!-- --></A><H3>nextLocation</H3><PRE>protected <A HREF="Location.html">Location</A> <B>nextLocation</B>()</PRE><DL><DD>Finds this fish's next location.  A darter fish darts forward two spaces if it can, otherwise it  tries to move forward one space.  A darter fish can only move  to empty locations, and it can only move two spaces forward if  the intervening space is empty.  If the darter fish cannot move  forward, <code>nextLocation</code> returns the fish's current  location.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="Fish.html#nextLocation()">nextLocation</A></CODE> in class <CODE><A HREF="Fish.html">Fish</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the next location for this fish</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"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>AP&reg; Computer Science Marine Biology Simulation</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="BoundedEnv.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="Debug.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>  &nbsp;&nbsp;<A HREF="DarterFish.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><i>Copyright&copy; 2002 College Entrance Examination Board</i></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -