1. The specification of an ADT describes only its properties (the domain and allowable operations). To implement the ADT, what two things must a programmer do? (pp.838840)
2. Write a C++ class declaration for the following Checkbook ADT. Do not implement the ADT other than to include in the private part a concrete data representation for the current balance. All monetary amounts are to be represented as floating point numbers.
TYPE
Checkbook
DOMAIN
Each instance of the Checkbook type is a value representing one customer's current checking account balance.
OPERATIONS
Open the checking account, specifying an initial balance.
Write a check for a specified amount.
Deposit a specified amount into the checking account.
Return the current balance.
(pp.842846)
3. Write a segment of client code that declares two Checkbook objects, one for a personal checkbook and one for a business account. (pp. 842846)
4. For the personal checkbook in Question 3, write a segment of client code that opens the account with an initial balance of $300.00, writes two checks for $50.25 and $150.00, deposits $87.34 into the account, and prints out the resulting balance. (pp. 846849)
5. Implement the following Checkbook member functions. (pp. 854858)
a. Open
b. WriteCheck
c. CurrentBalance
6. A compile-time error occurs if a client of Checkbook tries to access the private class members directly. Give an example of such a client statement. (pp. 850851)
7. In which filethe specification file or the implementation filewould the solution to Question 2 be located? In which file would the solution to Question 5 be located? (pp. 852858)
8. For the Checkbook class, replace the Open function with two C++ class constructors. One (the default constructor) initializes the account balance to zero. The other initializes the balance to an amount passed as a parameter. (pp. 863868)
a. Revise the class declaration.
b. Implement the two class constructors.
Answers 1. a. Choose a concrete data representation of the abstract data, using data types that already exist. b. Implement each of the allowable operations in terms of program instructions.
2. class Checkbook
{
public:
void Open( /* in */ float initBalance );
void WriteCheck( /* in */ float amount );