📄 exe3.html
字号:
</blockquote>
<p>The fields are separated by an underscore ( <code>_</code> ). You can assume
that the fields themselves do not contain any underscores.</p>
</li>
</ul>
<h4>Class <code>CoffeeBrewer</code></h4>
<p>Class <code>CoffeeBrewer</code> models a coffee
brewer. It extends class <code>Product</code>.</p>
<p><em>Instance variables:</em></p>
<ul>
<li><code><em>model</em></code>. The model of the coffee brewer<code></code></li>
<li><code><em>waterSupply</em></code>. The water supply (<code><em>Pour-over</em></code>
or <code><em>Automatic</em></code>)</li>
<li><code><em>numberOfCups</em></code>. The capacity of the coffee brewer<code></code></li>
</ul>
<p><em>Constructor and methods:</em></p>
<ul>
<li> <pre>public CoffeeBrewer(String initialCode,
String initialDescription,
double initialPrice,
String initialModel,
String initialWaterSupply,
int initialNumberOfCups)</pre>
<p>Constructor that initializes the instance variables <code>code</code>, <code>description</code>,
<code>price</code>, <code>model</code>, <code>waterSupply</code>, and <code>numberOfCups</code>.</p>
</li>
</ul>
<ul>
<li> <code><em>public String getModel()</em></code>. Returns the value of instance
variable <code>model</code>.</li>
</ul>
<ul>
<li> <code><em>public String getWaterSupply()</em></code>. Returns the value
of instance variable <code>waterSupply</code>.</li>
</ul>
<ul>
<li> <code><em>public int getNumberOfCups()</em></code>. Returns the value of
instance variable <code>numberOfCups</code>.</li>
</ul>
<ul>
<li><code><em>String toString()</em></code>. Overrides the method <code>toString</code>
in the class <code>Object</code>. Returns the string representation of a <code>CoffeeBrewer</code>
object. The <code>String</code> returned has the following format:
<blockquote>
<pre><em>code</em>_<em>description</em>_<em>price</em>_<em>model</em>_<em>waterSupply</em>_<em>numberOfCups</em></pre>
</blockquote>
<p>The fields are separated by an underscore ( <code>_</code> ). You can assume
that the fields themselves do not contain any underscores.</p>
</li>
</ul>
<h4>Class <code>OrderItem</code></h4>
<p>Class <code>OrderItem</code> models an item in an order. </p>
<p><em>Instance variables:</em></p>
<ul>
<li><code><em>product</em></code>. This instance variable represents the one-way
association between <code>OrderItem</code> and <code>Product</code>. It contains
a reference to a <code>Product</code> object.</li>
</ul>
<ul>
<li><code><em>quantity</em></code>. The quantity of the product in the order<code></code>.</li>
</ul>
<p><em>Constructor and methods:</em></p>
<ul>
<li>
<pre><em>public OrderItem(Product initialProduct,
int initialQuantity)</em></pre>
<p>Constructor that initializes the instance variables <code>product</code>
and <code>quantity</code>.</p>
</li>
</ul>
<ul>
<li> <code><em>public Product getProduct()</em></code>. Returns the value of
the instance variable <code>product</code>, a reference to a <code>Product</code>
object.</li>
</ul>
<ul>
<li> <code><em>public int getQuantity()</em></code>. Returns the value of the
instance variable <code>quantity</code>.</li>
</ul>
<ul>
<li> <code><em>public void setQuantity(int newQuantity)</em></code>. Sets the
instance variable <code>quantity</code> to the value of parameter <code>newQuantity</code>.</li>
</ul>
<ul>
<li> <code><em>public double getValue()</em></code>. Returns the product of
<code>quantity</code> and <code>price</code>.</li>
</ul>
<ul>
<li><code><em>String toString()</em></code>. Overrides the method <code>toString</code>
in the class <code>Object</code>. Returns the string representation of an
<code>OrderItem</code> object. The <code>String</code> representation has
the following format:
<blockquote>
<pre><em>quantity</em> <em>product-code</em> <em>product-price</em></pre>
</blockquote>
<p>The fields are separated by a space. You can assume that the fields themselves
do not contain any spaces.</p>
</li>
</ul>
<h4>Test driver classes</h4>
<p>Complete implementations of the following test drivers are provided in the
student archive. Use these test drivers to verify that your code works correctly.
</p>
<ul>
<li>Class <code>TestProduct</code></li>
<li>Class <code>TestCoffee</code> </li>
<li>Class <code>TestCoffeeBrewer</code> </li>
<li>Class <code>TestOrderItem</code></li>
</ul>
<h3>Files</h3>
The following files are needed to complete this assignment:
<ul>
<li><cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-impl-class/assm-exer-impl-class/pool-pr-impl-class/qn-pr-impl-class-cof-gou-sys/handout/student-files.zip"><code>student-files.zip</code></a></cite>
— Download this file. This archive contains the following:
<ul>
<li><cite><code>TestProduct.java</code></cite> </li>
<li><cite><code>TestCoffee.java</code></cite> </li>
<li><cite><code>TestCoffeeBrewer.java</code></cite> </li>
<li><cite><code>TestOrderItem.java</code></cite> </li>
</ul>
</li>
</ul>
<h3>Tasks </h3>
<p>Implement classes <code>Product</code>, <code>Coffee</code>, <code>CoffeeBrewer</code>,
and <code>OrderItem</code>. Document using Javadoc and follow Sun's code conventions.
The following steps will guide you through this assignment. Work incrementally
and test each increment. Save often. </p>
<ol start="1">
<li><strong>Extract </strong> the files by issuing the following command at
the command prompt:
<p><tt>C:\></tt><kbd>unzip student-files.zip</kbd> </p>
</li>
<li><strong>Then</strong>, implement class <code>Product</code> from scratch.<strong>
</strong>Use <code>TestProduct</code> driver to test your implementation.</li>
</ol>
<ol start="3">
<li><strong>Next</strong>, implement class <code>Coffee</code> from scratch.<strong>
</strong>Use <code>TestCoffee</code> driver to test your implementation.</li>
</ol>
<ol start="4">
<li><strong>Then</strong>, implement class <code>CoffeeBrewer</code>
from scratch. Use <code>TestCoffeeBrewer</code> driver to test your
implementation.</li>
</ol>
<ol start="5">
<li><strong>Finally</strong>, implement class <code>OrderItem</code> from scratch.
Use <code>TestOrderItem</code> driver to test your implementation.</li>
</ol>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following:</p>
<ol>
<li><code>Product.java</code> </li>
<li><code>Coffee.java</code></li>
<li><code>CoffeeBrewer.java</code> </li>
<li><code>OrderItem.java</code> </li>
</ol> </td>
<td width="5"><br></td></tr></tbody></table>
<a name="14327"></a><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#top_14327">Go to top of question.</a> </td>
<td width="5"><br></td></tr></tbody></table>
<hr><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"><label class="lbl0-x" for="file_to_add_14327">File to submit:</label><br> <input class="x" name="file_to_add_14327" value="" size="20" maxlength="500" type="file"> </td>
<td width="5"><br></td><td valign="bottom"> <input class="x" value="Upload File" name="add_file" id="add_file" style="width: 12em;" onclick='return SetUploadTime("https://seqcc.icarnegie.com:443/takeassmcmd.php?question_id=14327", 14327, false)' type="submit"></td><td width="5"><br></td></tr></tbody></table>
<hr><input name="pr_state_14327" id="pr_state_14327" value="a:2:{i:0;s:10:"incomplete";i:1;a:0:{}}" type="hidden"><table><tbody><tr>
</tr></tbody></table>
<input name="max_mins_per_try" id="max_mins_per_try" value="120" type="hidden"> <input value="2008-11-29 10:52:43 UTC" id="end_date" name="end_date" type="hidden"> <input value="421063" id="course_section_id" name="course_section_id" type="hidden"> <input value="14324" id="assm_id" name="assm_id" type="hidden"> <input value="657769" id="template_id" name="template_id" type="hidden"> <input value="657770" id="record_id" name="record_id" type="hidden"> <input value="" id="client_time" name="client_time" type="hidden"><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#top_of_page">Go to top of assessment.</a> </td>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_copyright" align="left" valign="top"> ? Copyright 2006 iCarnegie, Inc. All rights reserved. </td>
</tr></tbody></table>
</form>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -