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

📄 index.html

📁 《Big C++ 》Third Edition电子书和代码全集-Part1
💻 HTML
📖 第 1 页 / 共 3 页
字号:

<hr><h2><font color="#009999">25.5 State Diagrams</font></h2>
<font size="+1">

<table>
	<tr>
		<td width='65%' valign="top"><font size="+1">
			<ul>
				<li>Describe a discrete set of states that affect behavior</li>
				<li>Lists the transitions (some event) between the states</li>
				<li>E.g., to retrieve recent messages, user must
					<ul>
						<li>Enter mailbox #</li>
						<li>Enter passcode</li>
						<li>Enter menu command</li>
					</ul>
				</li>
			</ul>
		</font></td>
		<td align='left'>
			<script><!-- 
				image( "fig10.png" )
			//--></script>
		</td>
	</tr>
<table>

</font>

<hr><h2><font color="#009999">25.6 Case Study: A Voice Mail System</font></h2>
<font size="+1">

<ul>
	<li>Simulation of a simple voice mail system</li>
	<li>3 events:
		<ul>
			<li>Press a button - a single numeric character ('<tt>#</tt>' denotes
				end of sequence)</li>
			<li>Hang up - '<tt>H</tt>' by itself</li>
			<li>Speak - any other input</li>
		</ul>
	</li>
	<li><b>Analysis phase</b>:  first formal step</li>
		<ul>
			<li>Define behavior of system through use cases</li>
			<li><i>Not</i> a full spec (limitations, performance, etc.)</li>
		</ul>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System
	</font></h2>
<font size="+1">

<h3>Reach an Extension</h3>

<ol>
	<li>The caller dials main # of system</li>
	<li>System speaks prompt:<br>
		<tt>Enter mailbox number followed by #</tt>
	</li>
	<li>Caller enters number of recipient</li>
	<li>System speaks:<br>
		<tt>You have reached mailbox xxxx.  Please leave message.</tt>
	</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3>Leave a Message</h3>

<ol>
	<li>Caller <b>Reaches an Extension</b></li>
	<li>Caller speaks msg</li>
	<li>Caller hangs up</li>
	<li>System places msg in recipient's mailbox</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3>Log in</h3>

<ol>
	<li>Mailbox owner <b>Reaches an Extension</b></li>
	<li>Owner enters the passcode, followed by # key.  (Default passcode same
	as mailbox number.  Owner may <b>Change the Passcode</b>)</li>
	<li>System plays mailbox menu:<br>
		<tt>Enter 1 to retrieve your msgs<br>
			Enter 2 to change your passcode</br>
			Enter 3 to change your greeting</tt>
	</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3>Retrieve Messages</h3>

<ol>
<li>Owner <b>Logs in</b></li>
<li>Owner selects "<tt>retrieve msgs</tt>" option</li>
<li>System speaks msg menu:<br>
	<tt>
		Enter 1 to listen to current msg<br>
		Enter 2 to save current msg</br>
		Enter 3 to delete current msg</br>
		Enter 4 to return to mailbox menu</tt>
</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
</font></h2>
<font size="+1">

<h3>Retrieve Messages (cont.)</h3>

<ol start='4'>
<li>Owner selects "<tt>listen to current msg</tt>" option</li>
<li>System plays current new msg; if none exists, plays current old msg.
	Neither queue is changed</li>
<li>System speaks msg menu</li>
<li>Owner selects "<tt>delete current msg</tt>" option.  Msg permanently
	removed</li>
<li>Go back to Step 3</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
</font></h2>
<font size="+1">

<h4>Variation #I. Saving a message</h4>
<table>
<tr>
	<td valign='top' width="10%">1.1</td>
	<td>Start at Step 6</td>
</tr>
<tr>
	<td valign='top' width="10%">1.2</td>
	<td>Owner selects "<tt>save current msg</tt>".  Msg is removed from its
		queue, added to queue of old msgs.</td>
</tr>
<tr>
	<td valign='top' width="10%">1.3</td>
	<td>Go back to Step 3</td>
</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
</font></h2>
<font size="+1">

<h3>Change the Greeting</h3>

<ol>
<li>Owner <b>Logs in</b></li>
<li>Owner selects "<tt>change your greeting</tt>" option</li>
<li>Owner speaks the greeting</li>
<li>Owner presses the <tt>#</tt> key</li>
<li>System sets the new greeting</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
</font></h2>
<font size="+1">

<h4>Variation #I.  Hang up before confirmation</h4>
<table>
<tr>
	<td valign='top' width="10%">1.1</td>
	<td>Start at Step 3</td>
</tr>
<tr>
	<td valign='top' width="10%">1.2</td>
	<td>Owner hangs up (disconnects)</td>
</tr>
<tr>
	<td valign='top' width="10%">1.3</td>
	<td>System keeps old greeting</td>
</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
</font></h2>
<font size="+1">

<h3>Change the Passcode</h3>

<ol>
<li>Owner <b>Logs in</b></li>
<li>Owner selects "<tt>change your passcode</tt>" option</li>
<li>Owner types new passcode</li>
<li>Owner presses the <tt>#</tt> key</li>
<li>System sets the new passcode</li>
</ol>

</font>

<hr><h2><font color="#009999">25.6.1 Use Cases for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h4>Variation #I.  Hang up before confirmation</h4>
<table>
	<tr>
		<td valign='top' width="10%">1.1</td>
		<td>Start at Step 3</td>
	</tr>
	<tr>
		<td valign='top' width="10%">1.2</td>
		<td>Owner hangs up (disconnects)</td>
	</tr>
	<tr>
		<td valign='top' width="10%">1.3</td>
		<td>System keeps old passcode</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System
	</font></h2>
<font size="+1">

<ul>
	<li>Discover classes</li>
	<li>Nouns from the functional specification:
		<ul>
			<li>Mailbox</li>
			<li>Message</li>
			<li>MailSystem</li>
		</ul>
	</li>
</ul>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><tt>Mailbox</tt></h3>
<ul>
	<li>Keeps messages</li>
	<li>Track new vs. saved msgs</li>
	<li>Messages can be
		<ul>
			<li>Deposited in mailbox</li>
			<li>Retrieved</li>
			<li>Saved</li>
			<li>Deleted</li>
		</ul>
	</li>
	<li>Need FIFO - use queues</li>
	<li>New vs. saved - use 2 queues</li>
	<li>CRCs, so far:
</ul>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<table cellpadding="5">
	<tr>
		<td>
			<script><!-- 
				image( "un01.png" )
			//--></script>
		</td>
		<td>
			<script><!-- 
				image( "un02.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><tt>MailSystem</tt></h3>

<table cellpadding="5">
	<tr>
		<td valign="top">
			<ul>
				<li>Need a class to manage mailboxes:</li>
			</ul>
		</td>
		<td width="450">
			<script><!-- 
				image( "un03.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><tt>Telephone</tt> (simulation)</h3>

<table>
	<tr>
		<td valign="top">
			<ul>
				<li>Take user input</li>
				<li>Play (display) output on speaker</li>
			</ul>
		</td>
		<td width="450">
			<script><!-- 
				image( "un04.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><tt>Connection</tt></h3>

<table>
	<tr>
		<td valign="top">
			<ul>
				<li>Multiple phones connected to system</li>
				<li>Each connection keeps track of current state</li>
				<li>Create a separate class, to avoid bogging down system</li>
				<li>Driver responsible for creation of <tt>Telephone</tt>,
					<tt>MailSystem</tt>, and <tt>Connection</tt></li>
			</ul>
		</td>
		<td width="450">
			<script><!-- 
				image( "un05.png" )
			//--></script>
		</td>
	</tr>
</table>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><b>Leave a Msg</b> use case - simple scenario walkthrough</h3>

<ol>
	<li>User types an extension:
		<ul>
			<li><tt>Telephone</tt> sends number to <tt>Connection</tt></li>
			<li><tt>Connection</tt> collaborator of <tt>Telephone</tt></li>
			<li>Place the 2 cards adjacent)</li>
		</ul>
	</li>
	<li><tt>Connection</tt> asks <tt>MailSystem</tt> to find appropriate
		<tt>MailBox</tt> object
		<ul>
			<li>Vaguely included in the "manage mailboxes" responsibility</li>
			<li>Keep <tt>MailSystem</tt> and <tt>Mailbox</tt> cards close to
				<tt>Connection</tt> card</li>
		</ul>
	</li>
	<li><tt>Connection</tt> asks <tt>Mailbox</tt> for its greeting
		<ul>
			<li>Add "manage greeting" to <tt>Mailbox</tt> responsibilities</li>
			<li>add <tt>Mailbox</tt> as a collaborator of <tt>Connection</tt></li>
		</ul>
	</li>
</ol>

<p><i>(cont.)</i>

</font>

<hr><h2><font color="#009999">25.6.2 CRC Cards for the Voice Mail System (cont.)
	</font></h2>
<font size="+1">

<h3><b>Leave a Msg</b> use case (cont.)</h3>

<ol start="4">
	<li><tt>Connection</tt> asks <tt>Telephone</tt> to play greeting</li>
	<li>User speaks the msg:
		<ul>
			<li><tt>Telephone</tt> asks Connection to record it</li>
			<li>Add "record voice input" responsibility to <tt>Connection</tt></li>
		</ul>
	</li>
	<li>User hangs up:
		<ul>
			<li><tt>Telephone</tt> notifies <tt>Connection</tt></li>
		</ul>
	</li>
	<li><tt>Connection</tt> wraps the msg in a <tt>Message</tt> object
		<ul>
			<li>Add <tt>Message</tt> as a collaborator of <tt>Connection</tt></li>
			<li>Make a <tt>Message</tt> card with responsibility "manage msg
				contents"</li>
		</ul>
	</li>
	<li>The <tt>Connection</tt> adds the <tt>Message</tt> object to
		<tt>MailBox</tt></li>
</ol>

⌨️ 快捷键说明

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