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

📄 exe7.html

📁 卡耐基课程练习
💻 HTML
字号:
<span class="dialogueheader">Take Assessment: Exercise 7</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="657873" type="hidden"><table><tbody><tr>
  </tr></tbody></table>
<input name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="512000" type="hidden"><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>
  <td width="5"><br></td></tr></tbody></table>
<a name="top_14952"></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="#14952">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 070103 ici --> 
<h2 align="center">Implementing a GUI for the Gourmet Coffee System (Part I)</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>Graphical user interface (GUI)</em>
<ul>
        <li>Knowledge of Swing components and containers</li>
      </ul>
  </li></ul>
  <p> <b><i>Goals:</i></b> Reinforce your ability to create a GUI using Swing
  </p><p> <b><i>Outcomes:</i></b> You will master the following skills: 
  </p><ul>

    <li> Produce applications that use a Swing GUI</li>
  </ul>
</blockquote>
<h3>Background </h3>

<p>In this assignment, you will create a GUI that displays the <em>Gourmet Coffee 
  System</em>'s product catalog. Part of the work has been done for you and is 
  provided in the student archive. You will complete the code that creates a 
  graphical presentation of the product details. </p>
<h3>Description</h3>
<p>Class <code>CatalogGUI</code> lets the user display the product details of 
  every product in the gourmet coffee store's product catalog. This simple GUI 
  contains the following components: </p>

<ul>
  <li>a <code>JList</code> that displays the product code of every product in 
    the catalog</li>
  <li>a <code>JPanel</code> that presents product details</li>
  <li>a <code>JTextArea</code> that serves as a status area</li>

</ul>
<p>To examine the details of a particular product, the user selects the product 
  code in the list. The application responds by displaying the product details 
  in the <code>JPanel</code> and a status message in the <code>JTextArea</code>.</p>
<blockquote>
<table border="0" cellpadding="2" cellspacing="2" width="75%">
    <tbody><tr> 
      <td><img src="/content/SSD/SSD3/4.2.0.1/normal/pg-adv-class-impl/pg-gui/assm-exer-gui/pool-pr-gui/qn-pr-bsc-gui-gou-cof/handout/images/catalog-gui-cof-gou.jpg" alt="Execution of CatalogGUI" height="320" width="380"></td>
    </tr>
    <tr> 
      <td><b>Figure 1</b> <i>Execution of CatalogGUI</i></td>

    </tr>
  </tbody></table>
</blockquote>
<p>The following class diagram highlights the classes used to implement the GUI: 
</p>

<blockquote> 
  <table border="0" cellpadding="2" cellspacing="2" width="75%">
  <tbody><tr>
      <td><img src="/content/SSD/SSD3/4.2.0.1/normal/pg-adv-class-impl/pg-gui/assm-exer-gui/pool-pr-gui/qn-pr-bsc-gui-gou-cof/handout/images/uml-catalog-gui.jpg" alt="Portion of Gourmet Coffee System class diagram "></td>
  </tr>
  <tr>

      <td><b>Figure 2</b> <i>Portion of Gourmet Coffee System class 
        diagram </i></td>
  </tr>
</tbody></table>
</blockquote>

<p>Class <code>CatalogGUI</code> instantiates the Swing components, arranges the 
  components in a window, and handles the events generated by the list. In this assignment, you will implement  the method <code>getDataFieldsPanel</code> that returns a <code>JPanel</code> displaying the product details. An incomplete 
  implementation of <code>CatalogGUI</code> is provided in the student archive.</p>

<p>Class <code>DataField</code> contains a name/value pair that represents a single   attribute that is stored within an object. A complete implementation of <code>DataField</code> is 
  provided in the student archive.</p>
<p>Classes <code>Product</code>, <code>Coffee</code>, and <code>CoffeeBrewer</code> have been enhanced to add a method called 
  <code>getDataFields</code> that returns an <code>ArrayList</code> of <code>DataField</code> objects with the product details:</p>

<ul>
  <li>In class <code>Product</code>, the method <code>getDataFields</code> returns an <code>ArrayList</code> with <code>DataField</code> objects for the attributes "code", "description" and "price". </li>
</ul>
<ul>

  <li>In class <code>Coffee</code>, the method <code>getDataFields</code> returns an <code>ArrayList</code> with <code>DataField</code> objects for the attributes "code", "description", "price", "origin", "roast", "flavor", "aroma", "acidity" and "body".
</li>
</ul>
<ul>
  <li>In class <code>CoffeeBrewer</code>, the method <code>getDataFields</code> returns an <code>ArrayList</code> with <code>DataField</code> <code> </code>for the attributes "code", "description", "price", "model", "waterSupply" and "numberOfCups".</li>

</ul>
<p> A complete implementation of classes <code>Product</code>, <code>Coffee</code>, and <code>CoffeeBrewer</code> are provided in the student archive.</p>
<p>Class <code>Catalog</code> has been enhanced: it now contains a method called 
  <code>getCodes</code> that returns an array of product codes (all the product 
  codes in the product catalog) which <code>CatalogGUI</code> uses to populate 
  the <code>JList</code>. A complete implementation of <code>Catalog </code> is 
  provided in the student archive.</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-adv-class-impl/pg-gui/assm-exer-gui/pool-pr-gui/qn-pr-bsc-gui-gou-cof/handout/student-files.zip"><code>student-files.zip</code></a></cite> 
    — Download this file. This archive contains the following: 
    <ul>
      <li>Class files 
        <ul>
          <li><cite><code>Product.class</code></cite></li>
          <li><cite><code>Coffee.class</code></cite></li>

          <li><cite><code>CoffeeBrewer.class</code></cite></li>
          <li><cite><code>Catalog.class</code></cite></li>
          <li><cite><code>CatalogLoader.class</code></cite></li>
          <li><code><cite>File</cite></code><cite><code>CatalogLoader.class</code></cite></li>
          <li><cite><code>DataFormatException.class</code></cite></li>
          <li><cite><code>DataField.class</code></cite></li>

        </ul>
      </li>
      <li>Documentation 
        <ul>
          <li><cite><code>Product.html</code></cite></li>
          <li><cite><code>Coffee.html</code></cite></li>
          <li><cite><code>CoffeeBrewer.html</code></cite></li>
          <li><cite><code>Catalog.html</code></cite></li>

          <li><cite><code>CatalogLoader.html</code></cite></li>
          <li><code><cite>File</cite></code><cite><code>CatalogLoader.html</code></cite></li>
          <li><cite><code>DataFormatException.html</code></cite></li>
          <li><cite><code>DataField.html</code></cite></li>
        </ul>
      </li>

      <li>Java files
        <ul>
          <li><cite><code>CatalogGUI.java</code></cite>— a complete implementation</li>
        </ul>
      </li>
      <li>Data files for the test driver 
        <ul>
          <li><cite><code>catalog.dat</code></cite> — a file with product 
            information for every product in the product catalog</li>

        </ul>
      </li>
    </ul>
  </li>
</ul>
<h3>Tasks </h3>
<p>The following steps will guide you through this assignment. 
  Work incrementally and test each increment. Follow 
  Sun's code conventions. Save often.</p>
<ol start="1">
  <li><strong>Extract </strong> the files by issuing the following command at 
    the command prompt: 
    <p><tt>C:\&gt;</tt><kbd>unzip student-files.zip</kbd> </p>

  </li>
  <li><strong>Then</strong>, complete the implementation of the method <code>getDataFieldsPanel</code> in the class <code>CatalogGUI</code>.
    <blockquote>
      <p><code>private JPanel getDataFieldsPanel(ArrayList&lt;DataField&gt;  dataFields)</code> — Returns a reference to a <code>JPanel</code> 
    object that shows the names and values of the <code>DataField</code> objects stored in the parameter <code>dataFields</code>:

</p>
    </blockquote>
  </li>
  <ul>
          
      
    <ul>
      <li>For a coffee product, <code>dataFields</code> contains  nine <code>DataField</code> objects with the names: "Code", "Description", "Price", "Origin", "Roast", "Flavor", "Aroma", "Acidity" and "Body".</li>

    </ul>
  </ul>
</ol>
<ol start="1">
  <ul>
    <ul>
      <li>For a coffee brewer, <code>dataFields</code> contains  six <code>DataField</code> objects with the names: "Code", "Description", "Price", "Model", "Water supply" and "Number of cups".</li>

    </ul>
  </ul>
</ol>
<ol start="1">
  <ul>
    <ul>
      <li>For a generic product, <code>dataFields</code> contains  three <code>DataField</code> objects with the names: "Code", "Description" and "Price".</li>

    </ul>
  </ul>
  <blockquote>
    <p>For each <code>DataField</code> object stored  in <code>dataFields</code>, the <code>JPanel</code> should contain a <code>JLabel</code> object with the 
    name of the attribute and an uneditable <code>JTextField</code> object with the value of the attribute. Use 
    the <code>JPanel</code> layering technique  to build the 
    <code>JPanel</code>. The arrangement of the <code>JPanel</code> need not match 
    Figure 1 exactly; any well-organized presentation of the attributes will be 
    acceptable. </p>

  </blockquote>
</ol>
<ol start="3">
  <li><strong>Finally</strong>, compile and execute the class <code>CatalogGUI</code>. </li>
</ol>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following.</p>

<ol>
  <li><code>CatalogGUI.java</code></li>
</ol>
 </td>
<td width="5"><br></td></tr></tbody></table>
<a name="14952"></a><table><tbody><tr>
<td width="5"><br></td>  <td class="td0_x" align="left" valign="top"> <a href="#top_14952">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_14952">File to submit:</label><br> <input class="x" name="file_to_add_14952" 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=14952", 14952, false)' type="submit"></td><td width="5"><br></td></tr></tbody></table>
<hr><input name="pr_state_14952" id="pr_state_14952" value="a:2:{i:0;s:10:&quot;incomplete&quot;;i:1;a:0:{}}" type="hidden"><table><tbody><tr>
  </tr></tbody></table>
<input name="max_mins_per_try" id="max_mins_per_try" value="" type="hidden">  <input value="" id="end_date" name="end_date" type="hidden">  <input value="421063" id="course_section_id" name="course_section_id" type="hidden">  <input value="14949" id="assm_id" name="assm_id" type="hidden">  <input value="657873" id="template_id" name="template_id" type="hidden">  <input value="657874" 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 + -