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

📄 readme.html

📁 java(sl275课程习题解module1-module3共7道习题的题目以及程序)
💻 HTML
字号:
<HTML>

<HEAD>
   <TITLE>SL275: Module3: Exercise #2: Create Customer Accounts</TITLE>
</HEAD>

<BODY  BGCOLOR=white>


<CENTER>
<H2>SL275: Module3: Identifiers, Keywords, and Types</H2>
<H3>Exercise #2: Create Customer Accounts</H3>
<H3>(level 2)</H3>
</CENTER>


<H3>Objective</H3>

<P>
In this exercise you will expand the Banking project by adding a
<TT>Customer</TT> class.  A customer will contain one <TT>Account</TT> object.
</P>

<CENTER> 
<TABLE BORDER=0 CELLSPACING=10 WIDTH=614>
<TR>
  <TD> <IMG SRC="UML.gif" BORDER=0 ALT="The UML Diagram of the Customer Class" WIDTH=614 HEIGHT=237> </TD>
</TR>
<TR>
  <TD>
    <FONT COLOR=blue>
    Note: please refer to Appendix G <I>UML Modeling in Java</I> to help
    understand this UML diagram.  For example, the <TT>account</TT> relationship
    can be implemented as a data attribute in the <TT>Customer</TT> class;
    eventhough, it is not mentioned in the "attributes" section of 
    the <TT>Customer</TT> class block.
    </FONT>
  </TD>
</TR>
</TABLE>
</CENTER> 

<H3>Directions</H3>

<P>
Start by changing your working directory to <TT>SL275/mod03/exercise2</TT> on your computer.

<OL>

  <LI>Make the <TT>banking</TT> directory.
      <P>

  <LI>Copy the Banking project files from
      the previous Banking lab to this directory.  Use a command such as:
<PRE>
cp ../../mod02/exercise3/banking/*.java banking/
</PRE>
      <P>

  <LI>Create the <TT>Customer</TT> class in the file <TT>Customer.java</TT>
      under the <TT>banking</TT> directory.  This directory represents the
      Java package structure for your program.  This class must implement
      the model in the above UML diagram.
	<OL>
	  <LI>declare three private object attributes: <TT>firstName</TT>, <TT>lastName</TT>, and
	      <TT>account</TT>
	  <LI>declare a public constructor that takes two parameters (<TT>f</TT> and <TT>l</TT>)
	      that populate the object attributes
	  <LI>declare two public accessors for the object attributes; these methods
	      <TT>getFirstName</TT> and <TT>getLastName</TT> simply return the appropriate attribute
	  <LI>declare the <TT>setAccount</TT> method to assign the <TT>account</TT> attribute
	  <LI>declare the <TT>account</TT> method to retrieve the <TT>account</TT> attribute
	</OL>
      <P>
<TT></TT>

  <LI>In the main <TT>exercise2</TT> directory, compile and run the <TT>TestBanking</TT> program.
      You shoud see the following output:
<PRE>
Creating the customer Jane Smith.
Creating her account with a 500.00 balance.
Withdraw 150.00
Deposit 22.50
Withdraw 47.62
Customer [Smith, Jane] has a balance of 324.88
</PRE>

</OL>

</P>


</BODY>

</HTML>

⌨️ 快捷键说明

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