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

📄 takeassmcmd.html

📁 ssd2 exercise4 的题目和答案
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html>
<head>
<link rel=stylesheet href="/css/cteform.css" type="text/css">
<title>Take Assessment: Exercise 4 &copy; 2002-2006 iCarnegie, Inc. - UI Version 3.18.1</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><META HTTP-EQUIV="Expires" CONTENT="-1"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"><script language="JavaScript" src="/js/cteform.js"></script>
<script language="JavaScript" src="/js/ctecoursespt.js"></script>
<script language="JavaScript" src="/js/cteajax.js"></script>
<script language="JavaScript">
function FetchReferencedContent(questionName, referencedName)
{
    var cmd =
	"https://www.icarnegie.com:443/fetchrefcontentcmd.php?id=10692391" + "&question_name=" + encodeURIComponent(questionName)
		       + "&name=" + encodeURIComponent(referencedName);

    var winName = questionName + referencedName.replace(/\./g, "_");

    window.open(cmd,
		winName.replace(/-/g, "_"),
		"height=600,width=700,toolbar=no,menubar=no,location=no,status=no,resizable,scrollbars").focus();
}

function ResetTarget()
{
    var f = document.forms["Assm"];
    f.target = "";
}

function SetUploadTime(targetCmd, questionId, enableReadyForGrading)
{
    var f = document.forms["Assm"];

    f.action = targetCmd;

    var elt = f.elements["client_time"];

    if (typeof(elt) != 'undefined') {
	var now = new Date();

	elt.value = CreateSortableDate(now.getUTCFullYear(),
				       now.getUTCMonth() + 1,
				       now.getUTCDate(),
				       now.getUTCHours(),
				       now.getUTCMinutes(),
				       now.getUTCSeconds());
    }

    if (f.elements["file_to_add_" + questionId].value == '') {
	alert('Please specify a file to upload.');

	return false;
    }

    if (enableReadyForGrading) {
	elt = f.elements["ready_for_grading"];

	if (typeof(elt) != 'undefined') {
	    elt.disabled = false;
	}

	var now = new Date();

	f.target = now.getUTCFullYear()
			+ '_' + (now.getUTCMonth() + 1)
			+ '_' + now.getUTCDate()
			+ '_' + now.getUTCHours()
			+ '_' + now.getUTCMinutes()
			+ '_' + now.getUTCSeconds();

	var w =
	    window.open("",
			f.target,
			"height=300,width=500,toolbar=no,menubar=no,scrollbars=no,resizable=yes");

	w.focus();
    }
    else {
	f.target = "";
    }

    return true;
}
</script></head><body onload="">
<span class=dialogueheader>Take Assessment: Exercise 4</span><br><br>
  <form name="Assm" id="Assm" method=POST action="https://www.icarnegie.com:443/submitassmcmd.php" enctype="multipart/form-data">
<td width=5><br></td><a name="top_of_page"></a><table><tr>
  <input type=hidden name="object_id" id="object_id" value='11170618' ></tr></table>
<table><tr>
<td width=5><br></td>  <td class=td0_instructions  align=left valign=top >
     <span 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.</span></td>
  <input type=hidden name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value='512000' ><td width=5><br></td></tr></table>
<a name="top_9710195"></a><table><tr>
<td width=5><br></td>  <td class=td0_highlight-label width=12 align=right valign=top nowrap >
     <span class=highlight-label >1.</span></td>
<td width=5><br></td>  <td valign=top class=td0_x align=left > <a href="#9710195">Go to bottom of question.</a> </td>
</tr></table>
<table><tr>
<td width=5><br></td>  <td valign=top class=td0_x align=left > <!-- new pg 042903 ici -->

<h2 align="center">Implementing the Collections in the Gourmet
  Coffee System </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>Collections</em>
<ul>
        <li>Use of class <code>ArrayList</code></li>
        <li>Use of iterators</li>
      </ul>
  </ul>
  <p> <b><i>Goals:</i></b> Reinforce your ability to implement classes that use 
    collections
<p> <b><i>Outcomes:</i></b> You
    will demonstrate mastery of the following: 
  <ul>
    <li>Implementing a Java class that uses collections</li>
  </ul>
</blockquote>
<h3>Background </h3>

<p>In this assignment, you will implement the  classes in
  the <em>Gourmet Coffee
   System</em> that use collections.</p>
<h3>Description</h3>
<p>The following class diagram of the <em>Gourmet Coffee System</em>  highlights
  the  classes that use collections:</p>

<blockquote>
<table cellpadding="2" width="75%" cellspacing="2" border="0">
  <tr>
      <td><img src="coll-cof-gou-sys.jpg" alt="Figure 1 Gourmet Coffee System class diagram"></td>
  </tr>
  <tr>
      <td><b>Figure 1 </b><i>Gourmet Coffee System class diagram</i></td>
  </tr>
</table>
</blockquote>

<p>Complete implementations of the following classes are provided in the student
   archive:</p>
<ul>
  <li><code>Coffee</code></li>
  <li><code>CoffeeBrewer</code></li>
  <li><code>Product</code></li>
  <li><code>OrderItem</code></li>
  <li><code>GourmetCoffee</code></li>
</ul>
<p>In this assignment, you will implement the following classes:</p>
<ul>
  <li><code>Catalog</code></li>
  <li><code>Order</code></li>
  <li><code>Sales</code></li>
  <li><code>GourmetCoffee</code></li>
</ul>
<p>The class specifications are as follows:</p>
<h4>Class <code>Catalog</code></h4>
<p>The class <code>Catalog</code> models  a product catalog. This class  implements the interface <code>Iterable&lt;Product&gt;</code> to being able to iterate through the products using the <code>for-each</code> loop.</p>
<p><em>Instance variables:</em></p>
<ul>
  <li><code><em>products</em></code> &#8212; An <code>ArrayList</code>  collection that contains references to instances 
    of class <code>Product</code>.</li>
</ul>
<p><em>Constructor and public methods:</em></p>
<ul>
  <li> <code><em>public Catalog()</em></code> &#8212; Creates the collection <code>products</code>, 
    which is initially empty.</li>
</ul>
<ul>
  <li> <code><em>public void addProduct(Product product)</em></code> &#8212; Adds the 
    specified product to the collection <code>products</code>.</li>
</ul>
<ul>
  <li> <code><em>public Iterator&lt;Product&gt; iterator()</em></code> &#8212; Returns an 
    iterator over the instances in the collection <code>products</code>.</li>
</ul>
<ul>
  <li> <code><em>public Product getProduct(String code)</em></code> &#8212; Returns a 
    reference to the <code>Product</code> instance with the specified code. Returns 
    <code>null</code> if there are no products in the catalog with the specified 
    code. </li>
</ul>
<ul>
  <li> <code><em>public int getNumberOfProducts()</em></code> &#8212; Returns the number 
    of instances in the collection <code>products</code>.</li>
</ul>
<h4>Class <code>Order</code></h4>
<p>The class <code>Order</code> maintains a list of order items. This class  implements the interface <code>Iterable&lt;OrderItem&gt;</code> to being able to iterate through the items using the <code>for-each</code> loop.</p>
<p><em>Instance variables:</em></p>
<ul>
  <li><code><em>items</em></code> &#8212; An <code>ArrayList</code>  collection  that contains references to instances 
    of class <code>OrderItem</code>.</li>
</ul>
<p><em>Constructor and public methods:</em></p>
<ul>
  <li> <code><em>public Order()</em></code> &#8212; Creates the collection <code>items</code>, 
    which is initially empty.</li>
</ul>
<ul>
  <li> <code><em>public void addItem(OrderItem orderItem)</em></code> &#8212; Adds the 
    specified order item to the collection <code>items</code>.</li>
</ul>
<ul>
  <li> <code><em>public void removeItem(OrderItem orderItem)</em></code> &#8212; Removes 
    the specified order item from the collection <code>items</code>.</li>
</ul>
<ul>
  <li> <code><em>public Iterator&lt;OrderItem&gt; iterator()</em></code> &#8212; Returns an iterator 
    over the instances in the collection <code>items</code>.</li>
</ul>
<ul>
  <li> <code><em>public OrderItem getItem(Product product)</em></code> &#8212; Returns 
    a reference to the <code>OrderItem</code> instance with the specified product. 
    Returns <code>null</code> if there are no items in the order with the specified 
    product.</li>
</ul>
<ul>
  <li> <code><em>public int getNumberOfItems()</em></code> &#8212; Returns the number 
    of instances in the collection <code>items</code>.</li>
</ul>
<ul>
  <li> <code><em>public double getTotalCost()</em></code> &#8212; Returns the total cost 
    of the order. </li>
</ul>
<h4>Class <code>Sales</code></h4>
<p>The class <code>Sales</code> maintains a list of the orders that have been 
  completed. This class  implements the interface <code>Iterable&lt;Order&gt;</code> to being able to iterate through the orders using the <code>for-each</code> loop.</p>
<p><em>Instance variables:</em></p>
<ul>
  <li><code><em>orders</em></code> &#8212; An <code>ArrayList</code>  collection that contains references to instances 
    of class <code>Order</code>.</li>
</ul>
<p><em>Constructor and public methods:</em></p>
<ul>

⌨️ 快捷键说明

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