?? pq6.html
字號:
<span class="dialogueheader">Take Assessment: Practical Quiz 6</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="657602" 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:43:39 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:43:39 GMT+0800.</td> <td width="5"><br></td></tr></tbody></table>
<a name="top_14336"></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="#14336">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"> <h2 align="center">Using Arrays</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> <em>Arrays</em>
<ul>
<li>Knowledge of arrays
<ul>
<li>Declaring arrays</li>
<li>Initializing arrays</li>
<li>Accessing array elements</li>
<li>Using for-loops to process arrays</li>
</ul>
</li>
</ul>
</li></ul>
<p> <b><i>Goals:</i></b> Reinforce your ability to use arrays
</p><p> <b><i>Outcomes:</i></b> You
will demonstrate mastery of the following:
</p><ul>
<li>Using arrays
<ul>
<li>Creating arrays
<ul>
<li>From a set of objects </li>
<li>From another array</li>
</ul>
</li>
<li>Processing arrays
<ul>
<li>Finding an array element with a specific characteristic
</li><li>Counting the number of array elements with a specific characteristic
</li><li>Invoking a method on each array element
</li><li>Finding the string representation of an array</li>
</ul>
</li>
</ul>
</li>
</ul>
</blockquote>
<h3>Background </h3>
<h3>Description</h3>
<p>In this assignment, you will finish the implementation of <code>EmployeeArray</code>,
a class with static methods for creating, analyzing, and manipulating arrays
of <code>Employee</code> objects. iCarnegie provides a test driver and the class
<code>Employee</code>.</p>
<h4>Class <code>Employee</code></h4>
<p>A complete implementation of this class is included in the student
archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
Stop <em>now</em> and review its documentation:</p>
<ul>
<li><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/Employee.html" target="externalWindow"><code><em>Employee.html</em></code></a>.
Documentation for class <code>Employee</code></li>
</ul>
<h4>Class <code>EmployeeArray</code></h4>
<p>A partial implementation of this class is included in the student archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
You should complete the implementation of every method in this class. </p>
<h4>Class <code>TestEmployeeArray</code></h4>
<p>This class is a test driver for class <code>EmployeeArray</code>. It contains
test cases for every method in the class. A complete implementation is included
in the student archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
You should use this class to test your implementation of <code>EmployeeArray</code>.</p>
<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-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/student-files.zip"><code>student-files.zip</code></a></cite>.
Download this file. This archive contains the following:
<ul>
<li><cite><code>Employee.java</code></cite>. A complete implementation</li>
<li> <cite><code>EmployeeArray.java</code></cite>. Use this template to
complete your implementation.</li>
<li><cite><code>TestEmployeeArray.java</code></cite>. A complete implementation</li>
</ul>
</li>
</ul>
<h3>Tasks </h3>
<p>Implement all methods in class <code>EmployeeArray</code>. 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>Test</strong> each method as soon as you finish writing it by issuing
the following command at the command prompt:
<p><tt>C:\></tt><kbd>java TestEmployeeArray</kbd> </p>
</li>
<li><strong>Implement</strong> the method <code>makeArray</code>.</li>
</ol>
<ul>
<li><code><em>public static Employee[] makeArray(Employee first, Employee second,
Employee third)</em></code>. This method takes three <code>Employee</code>
objects and returns an <code>Employee</code> array with three elements. The
first element of the array contains a reference to the first argument; the
second element contains a reference to the second argument; and the third
element contains a reference to the third argument.</li>
</ul>
<blockquote>
<p>For example, consider the following objects:</p>
<blockquote>
<pre>Employee[102,Mary Jones,60000.0]
Employee[101,Joe Smith,20000.0]
Employee[103,Richard Wong,40000.0]</pre>
</blockquote>
<p>If these objects are passed to <code>makeArray</code> in the indicated order,
<code>makeArray</code> will return the following array:</p>
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<p>Note: <code>Employee[<em>ID</em>,<em>name</em>,<em>salary</em>]</code> is
the string representation of an <code>Employee</code> object. </p>
</blockquote>
<ol start="4">
<li><strong>Implement</strong> the method <code>copyArray</code>. Use indexes to implement this method.</li>
</ol>
<ul>
<li><code><em>public static Employee[] copyArray(Employee[] array)</em></code>.
This method takes an <code>Employee</code> array and returns a <em>new</em>
array with the same elements in the same order. </li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<p>If <code>copyArray</code> is passed this array, it will return the following
array:</p>
</blockquote>
<ol start="5">
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<li><strong>Implement</strong> the method <code>getEmployee</code>. Use a <code>for-each</code> loop to implement this method.</li>
</ol>
<ul>
<li><code><em>public static Employee getEmployee(Employee[] array, int id)</em></code>.
This method takes two arguments, an <code>Employee</code> array and an employee
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -