📄 pq5.html
字号:
<span class="dialogueheader">Take Assessment: Practical Quiz 5</span><br><br>
<form name="Assm" id="Assm" method="post" action="https://seqcc.icarnegie.com:443/submitassmcmd.php" enctype="multipart/form-data">
<a name="top_of_page"></a><input name="object_id" id="object_id" value="657592" type="hidden"><table><tbody><tr>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_instructions" align="left" valign="top">
<label class="instructions">Please answer the following question(s).<br>
If the assessment includes multiple-choice questions, click the "Submit Answers" button when you have completed those questions.</label></td>
</tr></tbody></table>
<input name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="512000" type="hidden"><table><tbody><tr>
<td width="5"><br></td><script language="JavaScript">document.write('<td class=instructions>' + 'You have 120 minutes to take this assessment.' + '<br>' + 'Please complete this assessment by ' + ComputeLocalDate('2008-11-29 10:42:44 UTC') + '.' + '</td>');</script><td class="instructions">You have 120 minutes to take this assessment.<br>Please complete this assessment by Sat Nov 29 2008 18:42:44 GMT+0800.</td> <td width="5"><br></td></tr></tbody></table>
<a name="top_14240"></a><table><tbody><tr>
<td width="5"><br></td> <td class="td0_highlight-label" align="right" nowrap="nowrap" valign="top" width="12">
<label class="highlight-label">1.</label></td>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#14240">Go to bottom of question.</a> </td>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <!-- new pg 042903 ici -->
<h2 align="center"><cite>Athlete Scores</cite></h2>
<h3>Prerequisites, Goals, and Outcomes</h3>
<blockquote> <b><i>Prerequisites:</i></b> Before you begin this exercise, you
need mastery of the following:
<ul>
<li> <i>Unit testing</i>
<ul>
<li>Knowledge of unit testing</li>
</ul>
</li></ul>
<p> <b><i>Goals:</i></b> Reinforce your ability to write test drivers
</p><p> <b><i>Outcomes:</i></b> You
will demonstrate mastery of the following:
</p><ul>
<li>Producing a test driver that verifies the implementation of a Java class
</li></ul>
</blockquote>
<h3>Background</h3>
<p>In this assignment, you will write a test driver to verify that an untested
piece of code is working correctly. iCarnegie will provide the untested code
— a class called <code>AthleteScores</code>.</p>
<h3>Description</h3>
<h4>Class <code>AthleteScores</code></h4>
<p><code>AthleteScores</code> contains four instance variables: the name of an
athlete and the three scores.
A complete implementation of <code>AthleteScores</code>
is included in the student archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-impl-class/assm-qz-pr-unit-tstng/pool-pr-unit-tstng/qn-pr-athlete-scores/handout/student-files.zip"><code>student-files.zip</code></a></cite>. <code>AthleteScores</code> contains the following constructor
and methods:</p>
<ul>
<li><code><em>public AthleteScores(String initialName, double initialScoreOne,
double initialScoreTwo, double initialScoreThree)</em></code>. Constructor
that initializes the instance variables <code>name</code>, <code>scoreOne</code>,
<code>scoreTwo</code>, and <code>scoreThree</code>.</li>
</ul>
<ul>
<li><code><em>String getName()</em></code>. Returns the name of the athlete.</li>
</ul>
<ul>
<li><code><em>double getScoreOne()</em></code>. Returns the value of the athlete's
first score.</li>
</ul>
<ul>
<li><code><em>double getScoreTwo()</em></code>. Returns the value of the athlete's
second score.</li>
</ul>
<ul>
<li><code><em>double getScoreThree()</em></code>. Returns the value of the athlete's
third score.</li>
</ul>
<ul>
<li><code><em>void setScoreOne(double newScore)</em></code>. Modifies the value
of the athlete's first score.</li>
</ul>
<ul>
<li><code><em>void setScoreTwo(double newScore)</em></code>. Modifies the value
of the athlete's second score.</li>
</ul>
<ul>
<li><code><em>void setScoreThree(double newScore)</em></code>. Modifies the
value of the athlete's third score.</li>
</ul>
<ul>
<li><code><em>double getMinimum()</em></code>. Returns the smallest of the three
scores. </li>
</ul>
<ul>
<li><code><em>boolean equals(Object object)</em></code>. Overrides the method
<code>Object.equals</code>. Two <code>AthleteScores</code> objects are equal
if their names are equal.</li>
</ul>
<ul>
<li><code><em>String toString()</em></code>. Overrides the method <code>Object.toString</code>.
Returns the string representation of an <code>AthleteScores</code> object.
The <code>String </code>returned has the following format:
<blockquote>
<pre><em>name</em>,<em>scoreOne</em>,<em>scoreTwo</em>,<em>scoreThree</em></pre>
</blockquote>
<p>The fields are separated by a comma ( , ). You can assume that the fields
themselves do not contain any commas.</p>
</li>
</ul>
<h4>Class <code>TestAthleteScores</code></h4>
<p>The file TestAthleteScores.java is an incomplete test driver. This file is
included in the student archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-impl-class/assm-qz-pr-unit-tstng/pool-pr-unit-tstng/qn-pr-athlete-scores/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
Class <code>TestAthleteScores</code> contains the following methods<code></code>:</p>
<ul>
<li><code><em>public static void assertTrue(String message, boolean condition)</em></code>.
This method is complete and should not be modified. It displays a message,
in the standard error stream, if the value specified by parameter <code>condition</code>
is <code>false</code>. For example, if a designer wants to verify that two
integers are equal and display an error message if they are not, then the
designer could write:
<blockquote>
<p><code>assertTrue("1: integers are not equal", x == y);</code> </p>
</blockquote>
<p>If integers <em>x</em> and <em>y</em> are not equal, then <code>assertTrue</code>
will display the error message specified by the first parameter. The error
message begins with a number because it is often convenient to number error
messages. </p>
</li>
</ul>
<ul>
<li><code><em>public static void main(String[] args)</em></code>. This method
is incomplete. It should test each method in the class <code>AthleteScores</code>.
If an error is found, it should display an error message. </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-qz-pr-unit-tstng/pool-pr-unit-tstng/qn-pr-athlete-scores/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
Download this file. This archive contains the following:</li>
<ul>
<li><cite><code>AthleteScores.java</code></cite>. A complete implementation</li>
<li> <cite><code>TestAthleteScores.java</code></cite>. An incomplete implementation</li>
</ul>
</ul>
<h3>Tasks</h3>
<p>Complete the implementation of the test driver. Use the method <code>assertTrue</code>
to display an error message when a problem is found. Each error message should
contain a unique number. Document using Javadoc and follow Sun's code conventions.
</p>
<p>The following steps will guide you through this assignment. Work incrementally
and test each increment. Save often.</p>
<ol>
<li><strong>First, </strong>extract the student archives by issuing the following
command at the command prompt:
<p><tt>C:\></tt><kbd>unzip student-files.zip</kbd> </p>
</li>
</ol>
<ol start="2">
<li><strong>Then, </strong>write the code to test the accessors: <code>getName</code>,
<code>getScoreOne</code>, <code>getScoreTwo</code>, and <code>getScoreThree</code>.</li>
</ol>
<ol start="3">
<li><strong>Next, </strong>write the code to test the mutators: <code>setScoreOne</code>,
<code>setScoreTwo</code>, and <code>setScoreThree</code>.</li>
</ol>
<ol start="4">
<li><strong>Then, </strong>write the code to test the method <code>getMinimum</code>.
Include the following test cases:
<ul>
<li>Verify that it returns the first score when the first score is
the smallest score. </li>
<li>Verify that it returns the second score when the second score is
the smallest score. </li>
<li>Verify that it returns the third score when the third score is
the smallest score. </li>
</ul>
</li>
</ol>
<ol start="5">
<li><strong>Next, </strong>write the code to test the method <code>equals</code>.
Include the following test cases<code></code>:
<ul>
<li>Verify that it returns <code>true</code> when objects being compared
have the same name.</li>
<li>Verify that it returns <code>false</code> when objects being compared
do <em>not</em> have the same name.</li>
<li>Verify that it returns <code>false</code> when objects being compared
are not instances of <code>AthleteScores</code>.</li>
</ul>
</li>
</ol>
<ol start="6">
<li><strong>Finally, </strong>write the code to test the method <code>toString</code>.</li>
</ol>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following:</p>
<ol>
<li><code>TestAthleteScores.java</code> </li>
</ol> </td>
<td width="5"><br></td></tr></tbody></table>
<a name="14240"></a><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#top_14240">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_14240">File to submit:</label><br> <input class="x" name="file_to_add_14240" 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=14240", 14240, false)' type="submit"></td><td width="5"><br></td></tr></tbody></table>
<hr><input name="pr_state_14240" id="pr_state_14240" 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:42:44 UTC" id="end_date" name="end_date" type="hidden"> <input value="421063" id="course_section_id" name="course_section_id" type="hidden"> <input value="14237" id="assm_id" name="assm_id" type="hidden"> <input value="657592" id="template_id" name="template_id" type="hidden"> <input value="657593" 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 + -