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

📄 takeassmcmd.html

📁 ssd2 exercise4 的题目和答案
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  <li> <code><em>public Sales()</em></code> &#8212; Creates the collection <code>orders</code>, 
    which is initially empty.</li>
</ul>
<ul>
  <li> <code><em>public void addOrder(Order order)</em></code> &#8212; Adds the specified 
    order to the collection <code>orders</code>.</li>
</ul>
<ul>
  <li> <code><em>public Iterator&lt;Order&gt; iterator()</em></code> &#8212; Returns an iterator 
    over the instances in the collection <code>orders</code>.</li>
</ul>
<ul>
  <li> <code><em>public int getNumberOfOrders()</em></code> &#8212; Returns the number 
    of instances in the collection <code>orders</code>.</li>
</ul>
<h4>Class <code>GourmetCoffee</code></h4>
<p>The class <code>GourmetCoffee</code> creates a console interface to process store orders.  Currently, it includes 
    the complete implementation of some of the methods. The methods <code>displayNumberOfOrders</code> and <code>displayTotalQuantityOfProducts</code> are incomplete and should be implemented. The following is a screen shot of the interface:</p>
<blockquote>
	<table cellpadding="2" width="54%" cellspacing="2" border="0">
	  <tr>
		  
		
      <td><img width="430" height="149" src="exe-gourmet-coffee.jpg" alt="Figure 2 Execution of GourmetCoffee"></td>
	  </tr>
	  <tr>
		  
		<td><b>Figure 2</b> <i>Execution of GourmetCoffee</i></td>
	  </tr>
	</table>
</blockquote>
<p><em>Instance variables:</em></p>
<ul>
  <li><code><em>catalog</em></code> &#8212; A <code>Catalog</code> object with the products that can be sold.</li>
  <li><code><em>currentOrder</em></code> &#8212; An <code>Order</code> object with the information about the current order.</li>
  <li><code><em>sales</em></code> &#8212; A <code>Sales</code> object with  information about all the orders sold by the store.</li>
</ul>
<p><em>Constructor and public methods:</em></p>
<ul>
  <li> <code><em>public GourmetCoffeeSolution()</em></code> &#8212; Initializes the attributes <code>catalog</code>, <code>currentOrder</code> and <code>sales</code>. This constructor is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void displayCatalog</em></code> &#8212; Displays  the catalog. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void displayProductInfo()</em></code> &#8212; Prompts the user for a product code and displays  information about the specified product. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void displayOrder()</em></code> &#8212; Displays the products in the current order. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void addModifyProduct()</em></code> &#8212;  Prompts the user for a product code and  quantity. If the specified product is not already    	 part of the order, it is added; otherwise, the quantity of the    	  product is updated. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void removeProduct()</em></code> &#8212; Prompts the user for a product code and removes the specified product from the current order. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void saleOrder()</em></code> &#8212; Registers the sale of the current order. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void displayOrdersSold()</em></code> &#8212;  Displays the orders that have been sold. This method is complete and  should not be modified.</li>
</ul>
<ul>
  <li> <code><em>public void displayNumberOfOrders(Product product)</em></code> &#8212; Displays the number of orders that contain the specified product.  This method is incomplete and should be implemented.</li>
</ul>
<ul>
  <li> <code><em>public void displayTotalQuantityOfProducts()</em></code> &#8212; Displays the total quantity sold for  each product in the catalog. This method is incomplete and should be implemented.</li>
</ul>
<h4>Test driver classes</h4>
<p>Complete implementations of the following test drivers are provided in the
  student archive:</p>
<ul>
  <li>Class <code>TestCatalog</code> </li>
  <li>Class <code>TestOrder</code> </li>
  <li>Class <code>TestSales</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-collctns/assm-exer-impl-collctns/pool-pr-impl-collctns/qn-pr-collctns-cof-gou-sys/handout/student-files.zip"><code>student-files.zip</code></a></cite> 
    &#151; Download this file. This archive contains the following: 
    <ul>
      <li>Class files 
        <ul>
          <li><cite><code>Coffee.class</code> </cite></li>
          <li><cite><code>CoffeeBrewer.class</code> </cite></li>
          <li><cite><code>Product.class</code> </cite></li>
          <li><cite><code>OrderItem.class</code> </cite></li>
        </ul>
      </li>
      <li>Documentation 
        <ul>
          <li><cite><code>Coffee.html</code></cite> </li>
          <li><cite><code>CoffeeBrewer.html</code></cite> </li>
          <li><cite><code>Product.html</code></cite></li>
          <li><cite><code>OrderItem.html</code></cite> </li>
        </ul>
      </li>
      <li>Java files 
        <ul>
          <li><cite><code>GourmetCoffee.java</code></cite> &#151; An incomplete implementation.</li>
          <li><cite><code>TestCatalog.java</code></cite> &#151; A complete implementation.</li>
          <li><cite><code>TestOrder.java</code></cite> &#151; A complete implementation.</li>
          <li><cite><code>TestSales.java</code></cite> &#151; A complete implementation.</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>
<h3>Tasks </h3>
<p>Implement classes <code>Catalog</code>, <code>Order</code>, and <code>Sales</code>. 
  Document your code 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:\&gt;</tt><kbd>unzip student-files.zip</kbd> </p>
  </li>
  <li><strong>Then</strong>, implement class <code>Catalog</code> from scratch.<strong> 
    </strong>Use <code>TestCatalog</code> to test your implementation.</li>
</ol>
<ol start="3">
  <li><strong>Next</strong>, implement class <code>Order</code> from scratch.<strong> 
    </strong>Use <code>TestOrder</code> to test your implementation.</li>
</ol>
<ol start="5">
  <li><strong>Then</strong>, implement class <code>Sales</code> from scratch.
     Use <code>TestSales</code> to test your implementation.</li>
</ol>
<ol start="6">
  <li><b>Finally</b>, complete class <code>GourmetCoffee</code>.  
    It uses a <code>Catalog</code> object created by method <code>GourmetCoffee.loadCatalog</code> and a <code>Sales</code></code> object generated by method <code>GourmetCoffee.loadSales</code>. 
    To complete class <code>GourmetCoffee</code>, implement the following methods:</li>
</ol>
<blockquote>
  <ul>
    <li><code><em>public void displayNumberOfOrders(Product product)</em></code> &#8212; This method displays the number of orders in the <code>sales</code> object that contain the specified product. Compile and execute the class <code>GourmetCoffee</code>. Verify that the method <code><em>displayNumberOfOrders</em></code> works correctly. The following is the output that should be displayed for the  product with product code <code>A001</code> and the orders preloaded by the method <code>loadSales</code>:
<blockquote>
        <p><code>[0] Quit<br>
          [1] Display catalog<br>
          [2] Display product<br>
          [3] Display current order<br>
          [4] Add|modify product to|in current order<br>
          [5] Remove product from current order<br>
          [6] Register sale of current order<br>
          [7] Display sales<br>
          [8] Display number of orders with a specific product<br>
          [9] Display the total quantity sold for each product<br>
          choice&gt; <strong>8</strong></code></p>
        <p><code>Product code&gt; <strong>A001</strong><br>
          Number of orders that contains the product A001: 4</code></p>
      </blockquote>
    </li>
  </ul>
</blockquote>
<blockquote> 
  <ul>
    
    <li><code><em>public void displayTotalQuantityOfProducts()</em></code> &#8212; This method  displays  the total quantity  sold for each product in the catalog.
The information 
      of each product must be displayed on a single line in the following format:
      <p><var>ProductCode</var> <var>Quantity</var><var></var></p>
      <p>The following is a description of the information included in the format 
        above:</p>
    </li>
  </ul>
  <blockquote> 
    <ul>
      <li><var>ProductCode</var> &#151; the code of the product</li>
      <li><var>Quantity</var> &#151; the total quantity of product that has been sold in the store</li>
    </ul>
  </blockquote>
  <ul>
    <p>Compile and execute the class <code>GourmetCoffee</code>. Verify that the method <code>displayTotalQuantityOfProducts</code> works correctly. The following is the output that should be displayed for the orders preloaded by the method <code>loadSales</code>:</p>
    <blockquote>
      <p><code>[0] Quit<br>
        [1] Display catalog<br>
        [2] Display product<br>
        [3] Display current order<br>
        [4] Add|modify product to|in current order<br>
        [5] Remove product from current order<br>
        [6] Register sale of current order<br>
        [7] Display sales<br>
        [8] Display number of orders with a specific product<br>
        [9] Display the total quantity sold for each product<br>
        choice&gt; <strong>9</strong></code></p>
      <p><code>C001 9<br>
        C002 4<br>
        C003 5<br>
        C004 0<br>
        C005 8<br>
        B001 2<br>
        B002 1<br>
        B003 2<br>
        A001 12<br>
        A002 6<br>
        A003 5<br>
        A004 6<br>
        A005 0</code></p>
    </blockquote>
  </ul>
</blockquote>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following.</p>
<ol>
  <li><code>Catalog.java</code></li>
  <li><code>Order.java</code></li>
  <li><code>Sales.java</code></li>
  <li><code>GourmetCoffee.java</code></li>
</ol>
 </td>
<td width=5><br></td></tr></table>
<a name="9710195"></a><table><tr>
<td width=5><br></td>  <td valign=top class=td0_x align=left > <a href="#top_9710195">Go to top of question.</a> </td>
<td width=5><br></td></tr></table>
<hr><table><tr>
<td width=5><br></td>  <td valign=top class=td0_x align=left ><span class=lbl0-x>File to submit:</span><br> <input type=file class='x' name=file_to_add_9710195 value="" size=20 maxLength=500 > </td>
<td width=5><br></td><td valign=bottom>  <input class=x value="Upload File"  type=submit name=add_file id=add_file  style="width: 12em;" onClick='return SetUploadTime("https://www.icarnegie.com:443/takeassmcmd.php?question_id=9710195", 9710195, false)'></td><td width=5><br></td><td valign=bottom>  <input class=x value="Forward File"  type=submit name=mail_file id=mail_file  style="width: 12em;" onClick='return SetUploadTime("https://whu-cqc.icarnegie.com:443/mailuploadcmd.php?question_id=9710195", 9710195, true)'></td><td width=5><br></td><td valign=bottom>  <input class=x value="Refresh" onClick="ChangeCommand(document.Assm, 'https://www.icarnegie.com:443/refreshassmtakecmd.php?question_id=9710195')" type=submit   onfocus='ResetTarget()'></td><td width=5><br></td><td valign=bottom>  <input class=x-font value="Ready for Grading" onClick="ChangeCommand(document.Assm, 'https://www.icarnegie.com:443/takeassmcmd.php?question_id=9710195')" type=submit name=ready_for_grading id=ready_for_grading  style="width: 12em;" onfocus='ResetTarget()' disabled></td><td width=5><br></td></tr></table>
<hr><table><tr>
  <input type=hidden name="pr_state_9710195" id="pr_state_9710195" value='a:2:{i:0;s:10:&quot;incomplete&quot;;i:1;a:0:{}}' ></tr></table>
<table><tr>
<td width=5><br></td>  <td valign=top class=td0_x align=left > <a href="#top_of_page">Go to top of assessment.</a> </td>
  <input type=hidden name="assm_title" id="assm_title" value='Exercise 4' >  <input type=hidden name="max_mins_per_try" id="max_mins_per_try" value='' >  <input type=hidden name="end_date" id="end_date" value='' >  <input type=hidden name="course_section_id" id="course_section_id" value='10692391' >  <input type=hidden name="assm_id" id="assm_id" value='9710192' >  <input type=hidden name="template_id" id="template_id" value='11170618' >  <input type=hidden name="record_id" id="record_id" value='11170619' >  <input type=hidden name="client_time" id="client_time" value='' ></tr></table>
<table><tr>
<td width=5><br></td>  <td class=td0_copyright  align=left valign=top >
     <span class=copyright ><br>&#169; Copyright 2006 iCarnegie, Inc.  All rights reserved.</span></td>
</tr></table>
</form>

</body></html>

⌨️ 快捷键说明

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