Java Reference
In-Depth Information
declared in the abstract
class
BankAccount
. Some operations common to all types of
accounts are to retrieve the account owner's name, the account number, the account
balance, make deposits, withdraw money, and create a monthly statement. So we include
methods to implement these operations. Furthermore, some of these methods will be
abstract. We also include the method
toString
to return the appropriate information
about the class as a string. The UML class diagram of the
class
BankAccount
is shown
in Figure 10-8.
BankAccount (Abstract
class
)
#accountNumber:
int
#name: String
#balance:
double
+BankAccount(String,
int
,
double
)
+getAccountNumber():
int
+getBalance():
double
+getName(): String
+setName(String):
void
+withdraw(
double
):
void
+deposit(
double
):
void
+createMonthlyStatement():
abstract void
+String toString()
FIGURE 10-8
UML class diagram of the
class
BankAccount
CheckingAccount
: A checking account is a bank account. Therefore, it inherits all the
properties of a bank account. Because one of the objectives of a checking account is to be
able to write checks, we include the abstract method
writeCheck
to write checks. The
UML class diagram for
class
CheckingAccount
is shown in Figure 10-9.
1
0
CheckingAccount
+CheckingAccount(String,
int
,
double
)
+writeCheck(
double
):
abstract void
FIGURE 10-9
UML class diagram of the
class
CheckingAccount
ServiceChargeChecking
: A service charge checking account is a checking account.
Therefore, it inherits all the properties of a checking account. For simplicity we assume that
this type of account does not pay any interest, allows the account holder to write a limited
number of checks each month, and does not require any minimum balance. The named
constants, instance variables, and methods of this class are described in Figure 10-10, which
also shows the UML class diagram of the
class
ServiceChargeChecking
.
Search WWH ::
Custom Search