September 2001
Beginner
528 pages
11h 59m
English
To demonstrate a simple class, and how it is used, I have created BankAccount, a class that encapsulates the basic functionality of a bank account. It has a read-only balance property that returns the current account balance. The balance can be changed only by making deposits and withdrawals, which is done by methods. Withdrawals are permitted only if the balance is sufficient to cover them. Listing 18.5 shows the code for the BankAccount class, and Listing 18.6 shows a procedure that demonstrates how you would make use of the class. I have omitted saving and retrieving data, but that is easily implemented using a random or binary file.
Private pBalance ... |
Read now
Unlock full access