Part 3: Routines

 
 
 

3.1   Specification

        The specification is unchanged from part 2 of the case study.
 
 

3.2   Analysis

        The analysis is unchanged, because the specification is unchanged.
 
 

3.3   Solution design

        Class ACCOUNT is the root class for a system of one class, so the make routine has to call every other routine in the class; this is unusual. The monolithic chunk of code from the previous solution is divided into individual routines.

        The main routines in the class contain the code to deposit, withdraw, show_balance, and add_interest. The amount of interest to add is calculated from the balance and the interest rate, so it is a function. The daily interest rate is calculated from the annual interest rate by another function day_rate. I have added a show routine to help with debugging.

        The attribute amount has been deleted; io.lastreal is used instead.

        The client chart is unchanged.
 
 

3.4   Solution code

        The Ace file is unchanged. The listing for class ACCOUNT is given on the next page.